Skip to content
This repository has been archived by the owner on Aug 1, 2022. It is now read-only.

Commit

Permalink
Minor hdbdd field names refactor
Browse files Browse the repository at this point in the history
Signed-off-by: Boris Nenchovski <[email protected]>
  • Loading branch information
BorisNen committed Oct 26, 2021
1 parent aa32292 commit b6b7413
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,16 @@ public class XSKHdbddParser implements XSKDataStructureParser {
private HdbddTransformer hdbddTransformer = new HdbddTransformer();
private IRepository repository = (IRepository) StaticObjects.get(StaticObjects.REPOSITORY);
private SymbolTable symbolTable = new SymbolTable();
private Map<String, Set<String>> usedFiles = new HashMap<>();
private Set<String> currentlyParsed;
private Map<String, Set<String>> dependencyStructure = new HashMap<>();
private Set<String> parsedNodes = new HashSet<>();

@Override
public XSKDataStructureModel parse(String location, String content) throws XSKDataStructuresException, IOException {
XSKDataStructureCdsModel cdsModel = getCdsModelBaseData(location, content);
if (XSKHDBModule.getManagerServices().get(getType()).skipParse(cdsModel, usedFiles.get(location) != null)) {
if (XSKHDBModule.getManagerServices().get(getType()).isParsed(cdsModel, dependencyStructure.get(location) != null)) {
return null;
}
currentlyParsed = new HashSet<>();

for (String fileLocation : this.getFilesToProcess(location)) {
IResource loadedResource = this.repository.getResource("/registry/public/" + fileLocation);
String fileContent = new String(loadedResource.getContent());
Expand All @@ -87,7 +87,7 @@ public XSKDataStructureModel parse(String location, String content) throws XSKDa
getCdsModelWithParsedData(cdsModel);
this.symbolTable.clearSymbolsByFullName();
this.symbolTable.clearEntityGraph();
currentlyParsed = null;
parsedNodes.clear();

return cdsModel;
}
Expand Down Expand Up @@ -129,15 +129,15 @@ private void parseHdbdd(String location, String content) throws IOException, XSK

entityDefinitionListener.getPackagesUsed().forEach(p -> {
String fileLocation = getFileLocation(p);
addUsedFile(fileLocation, location);
if(!currentlyParsed.isEmpty() && currentlyParsed.contains(fileLocation)){
addFileToDependencyTree(fileLocation, location);
if(!parsedNodes.isEmpty() && parsedNodes.contains(fileLocation)){
return;
}

try {
IResource loadedResource = this.repository.getResource("/registry/public/" + fileLocation);
parseHdbdd(fileLocation, new String(loadedResource.getContent()));
currentlyParsed.add(fileLocation);
parsedNodes.add(fileLocation);
} catch (IOException | XSKArtifactParserException e) {
XSKCommonsUtils.logCustomErrors(location, XSKCommonsConstants.PARSER_ERROR, "", "", e.getMessage(),
"", XSKCommonsConstants.HDBDD_PARSER, XSKCommonsConstants.MODULE_PARSERS,
Expand All @@ -162,14 +162,14 @@ private void parseHdbdd(String location, String content) throws IOException, XSK
}
}

private void addUsedFile(String usedFile, String userFile) {
Set<String> userFiles = usedFiles.get(usedFile);
if (userFiles == null) {
userFiles = new HashSet<>();
private void addFileToDependencyTree(String nodeFile, String rootFile) {
Set<String> rootFiles = dependencyStructure.get(nodeFile);
if (rootFiles == null) {
rootFiles = new HashSet<>();
}

userFiles.add(userFile);
this.usedFiles.put(usedFile, userFiles);
rootFiles.add(rootFile);
this.dependencyStructure.put(nodeFile, rootFiles);
}

@Override
Expand All @@ -190,13 +190,13 @@ private List<String> getFilesToProcess(String fileLocation) {
}

private void getRootFiles(String usedFileName, List<String> rootFiles) {
Set<String> userFiles = usedFiles.get(usedFileName);
Set<String> userFiles = dependencyStructure.get(usedFileName);
if (userFiles == null) {
rootFiles.add(usedFileName);
return;
}

usedFiles.get(usedFileName).forEach(f -> {
dependencyStructure.get(usedFileName).forEach(f -> {
getRootFiles(f, rootFiles);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ void updateDataStructure(Connection connection, T tableModel)

void clearCache();

boolean skipParse(T tableModel, boolean parsedByRoot) throws XSKDataStructuresException;
boolean isParsed(T tableModel, boolean parsedByRoot) throws XSKDataStructuresException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,19 @@ public IXSKEntityManagerService() {
entitiesSynchronized = Collections.synchronizedList(new ArrayList<>());
}

public boolean skipParse(XSKDataStructureCdsModel entitiesModel, boolean parsedByRoot) throws XSKDataStructuresException {
public boolean isParsed(XSKDataStructureCdsModel entitiesModel, boolean parsedByRoot) throws XSKDataStructuresException {
XSKDataStructureCdsModel existingModel = getDataStructuresCoreService()
.getDataStructure(entitiesModel.getLocation(), entitiesModel.getType());
boolean isEmptyExistingModel = existingModel == null;

if (existingModel == null && parsedByRoot) {
if (isEmptyExistingModel && parsedByRoot) {
getDataStructuresCoreService()
.createDataStructure(entitiesModel.getLocation(), entitiesModel.getName(), entitiesModel.getHash(), entitiesModel.getType());
return true;
} else {
entitiesModel.setCreateDataStructure(existingModel == null);
return existingModel != null && existingModel.equals(entitiesModel);
}

entitiesModel.setCreateDataStructure(isEmptyExistingModel);
return !isEmptyExistingModel && existingModel.equals(entitiesModel);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public void clearCache() {
}

@Override
public boolean skipParse(XSKDataStructureHDBSequenceModel tableModel, boolean parsedByRoot) throws XSKDataStructuresException {
public boolean isParsed(XSKDataStructureHDBSequenceModel tableModel, boolean parsedByRoot) throws XSKDataStructuresException {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public void clearCache() {
}

@Override
public boolean skipParse(XSKDataStructureHDBProcedureModel tableModel, boolean parsedByRoot) throws XSKDataStructuresException {
public boolean isParsed(XSKDataStructureHDBProcedureModel tableModel, boolean parsedByRoot) throws XSKDataStructuresException {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public void clearCache() {
}

@Override
public boolean skipParse(XSKDataStructureHDBSchemaModel tableModel, boolean parsedByRoot) throws XSKDataStructuresException {
public boolean isParsed(XSKDataStructureHDBSchemaModel tableModel, boolean parsedByRoot) throws XSKDataStructuresException {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public void clearCache() {
}

@Override
public boolean skipParse(XSKDataStructureHDBSynonymModel tableModel, boolean parsedByRoot) throws XSKDataStructuresException {
public boolean isParsed(XSKDataStructureHDBSynonymModel tableModel, boolean parsedByRoot) throws XSKDataStructuresException {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public void clearCache() {
}

@Override
public boolean skipParse(XSKDataStructureHDBTableFunctionModel tableModel, boolean parsedByRoot) throws XSKDataStructuresException {
public boolean isParsed(XSKDataStructureHDBTableFunctionModel tableModel, boolean parsedByRoot) throws XSKDataStructuresException {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public void clearCache() {
}

@Override
public boolean skipParse(XSKDataStructureHDBTableModel tableModel, boolean parsedByRoot) throws XSKDataStructuresException {
public boolean isParsed(XSKDataStructureHDBTableModel tableModel, boolean parsedByRoot) throws XSKDataStructuresException {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public void clearCache() {
}

@Override
public boolean skipParse(XSKDataStructureHDBTableTypeModel tableModel, boolean parsedByRoot) throws XSKDataStructuresException {
public boolean isParsed(XSKDataStructureHDBTableTypeModel tableModel, boolean parsedByRoot) throws XSKDataStructuresException {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void clearCache() {
}

@Override
public boolean skipParse(XSKDataStructureHDBViewModel tableModel, boolean parsedByRoot) throws XSKDataStructuresException {
public boolean isParsed(XSKDataStructureHDBViewModel tableModel, boolean parsedByRoot) throws XSKDataStructuresException {
return false;
}
}

0 comments on commit b6b7413

Please sign in to comment.