ModelDeclaration sourceDecl = sourceModel.findDeclaration();
assert sourceDecl != null;
Map<String, PropertyDeclaration> results = new HashMap<String, PropertyDeclaration>();
if (term.mapping == null) {
for (PropertyDeclaration prop : sourceDecl.getDeclaredProperties()) {
PropertyDeclaration declared = model.findPropertyDeclaration(prop.getName().identifier);
if (declared != null) {
LOG.debug("property {} is duplicated", prop.getSymbol()); //$NON-NLS-1$
results.put(declared.getName().identifier, declared);
} else {
declared = model.declareProperty(
sourceModel.getName(),
prop.getName(),
prop.getType(),
prop.getDescription(),
prop.getAttributes());
results.put(declared.getName().identifier, declared);
}
}
} else {
Set<String> saw = Sets.create();
for (AstPropertyMapping property : term.mapping.properties) {
if (saw.contains(property.target.identifier)) {
report(new Diagnostic(
Level.ERROR,
property,
Messages.getString("DmdlAnalyzer.diagnosticDuplicatedJoinMappingProperty"), //$NON-NLS-1$
property.target.identifier));
continue;
}
saw.add(property.target.identifier);
PropertyDeclaration sourceProp = sourceDecl.findPropertyDeclaration(property.source.identifier);
if (sourceProp == null) {
report(new Diagnostic(
Level.ERROR,
sourceModel.getName(),
Messages.getString("DmdlAnalyzer.diagnosticMissingJoinProperty"), //$NON-NLS-1$
property.source.identifier,
sourceModel.getName().identifier));
continue;
}
PropertyDeclaration declared = model.findPropertyDeclaration(property.target.identifier);
if (declared != null) {
LOG.debug("property {} is duplicated", property.target); //$NON-NLS-1$
results.put(declared.getName().identifier, declared);
} else {
declared = model.declareProperty(
property,
property.target,
sourceProp.getType(),
property.description,
property.attributes);
results.put(declared.getName().identifier, declared);
}
}
}
return results;
}