use of com.amalto.workbench.detailtabs.sections.model.entity.KeyWrapper in project tmdm-studio-se by Talend.
the class EntityCommitHandler method commitKeyAddition.
private boolean commitKeyAddition() {
boolean hasChanges = false;
for (KeyWrapper eachKeyWrapper : getCommitedObj().getKeys()) {
if (!eachKeyWrapper.isUserCreated()) {
continue;
}
hasChanges = true;
XSDFactory factory = XSDSchemaBuildingTools.getXSDFactory();
XSDIdentityConstraintDefinition newKey = factory.createXSDIdentityConstraintDefinition();
newKey.setName(eachKeyWrapper.getName());
newKey.setIdentityConstraintCategory(eachKeyWrapper.getType());
XSDXPathDefinition selector = factory.createXSDXPathDefinition();
selector.setValue(eachKeyWrapper.getSelector());
selector.setVariety(XSDXPathVariety.SELECTOR_LITERAL);
newKey.setSelector(selector);
for (FieldWrapper newFields : eachKeyWrapper.getFields()) {
XSDXPathDefinition field = factory.createXSDXPathDefinition();
field.setValue(newFields.getXPath());
field.setVariety(XSDXPathVariety.FIELD_LITERAL);
newKey.getFields().add(field);
}
getCommitedObj().getSourceEntity().getIdentityConstraintDefinitions().add(newKey);
getCommitedObj().getSourceEntity().updateElement();
}
return hasChanges;
}
use of com.amalto.workbench.detailtabs.sections.model.entity.KeyWrapper in project tmdm-studio-se by Talend.
the class EntityCommitHandler method getNeedRemovedKeys.
private XSDIdentityConstraintDefinition[] getNeedRemovedKeys() {
List<XSDIdentityConstraintDefinition> curLeftSourceKeys = new ArrayList<XSDIdentityConstraintDefinition>();
List<XSDIdentityConstraintDefinition> needRemovedKeys = new ArrayList<XSDIdentityConstraintDefinition>();
for (KeyWrapper eachKeyWrapper : getCommitedObj().getKeys()) {
if (!eachKeyWrapper.isUserCreated()) {
curLeftSourceKeys.add(eachKeyWrapper.getSourceKey());
}
}
for (XSDIdentityConstraintDefinition eachSourceKey : getCommitedObj().getSourceEntity().getIdentityConstraintDefinitions()) {
if (!curLeftSourceKeys.contains(eachSourceKey)) {
needRemovedKeys.add(eachSourceKey);
}
}
return needRemovedKeys.toArray(new XSDIdentityConstraintDefinition[0]);
}
use of com.amalto.workbench.detailtabs.sections.model.entity.KeyWrapper in project tmdm-studio-se by Talend.
the class EntityCommitHandler method validateEntityKeys.
private void validateEntityKeys() throws CommitValidationException {
for (KeyWrapper eachKeyWrapper : getCommitedObj().getKeys()) {
validateEachKey(eachKeyWrapper);
}
validateKeyUnique();
validateDuplicateKeyNameInEntityWrapper();
}
Aggregations