use of com.amalto.workbench.detailtabs.sections.model.entity.FieldWrapper in project tmdm-studio-se by Talend.
the class EntityCommitHandler method validateEachKey.
private void validateEachKey(KeyWrapper checkedKeyWrapper) throws CommitValidationException {
validateEachKeyName(checkedKeyWrapper);
validateEachKeySelector(checkedKeyWrapper);
validateEachKeyFieldsCount(checkedKeyWrapper);
for (FieldWrapper eachFieldWrapper : checkedKeyWrapper.getFields()) {
validateEachField(checkedKeyWrapper, eachFieldWrapper);
}
}
use of com.amalto.workbench.detailtabs.sections.model.entity.FieldWrapper 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.FieldWrapper in project tmdm-studio-se by Talend.
the class EntityCommitHandler method commitKeyUpdate_Fields_Update.
private boolean commitKeyUpdate_Fields_Update(KeyWrapper keyWrapper) {
boolean hasChanges = false;
for (FieldWrapper eachField : keyWrapper.getFields()) {
if (eachField.isUserCreated()) {
continue;
}
if (eachField.getSourceField().getValue().equals(eachField.getXPath())) {
continue;
}
eachField.getSourceField().setValue(eachField.getXPath());
eachField.getSourceField().updateElement();
hasChanges = true;
}
return hasChanges;
}
use of com.amalto.workbench.detailtabs.sections.model.entity.FieldWrapper in project tmdm-studio-se by Talend.
the class EntityCommitHandler method getNeedRemovedFields.
private XSDXPathDefinition[] getNeedRemovedFields(KeyWrapper keyWrapper) {
List<XSDXPathDefinition> curLeftFields = new ArrayList<XSDXPathDefinition>();
List<XSDXPathDefinition> needRemovedFields = new ArrayList<XSDXPathDefinition>();
for (FieldWrapper eachField : keyWrapper.getFields()) {
if (!eachField.isUserCreated()) {
curLeftFields.add(eachField.getSourceField());
}
}
for (XSDXPathDefinition eachSourceField : keyWrapper.getSourceKey().getFields()) {
if (!curLeftFields.contains(eachSourceField)) {
needRemovedFields.add(eachSourceField);
}
}
return needRemovedFields.toArray(new XSDXPathDefinition[0]);
}
use of com.amalto.workbench.detailtabs.sections.model.entity.FieldWrapper in project tmdm-studio-se by Talend.
the class EntityCommitHandler method commitKeyUpdate_Fields_Addition.
private boolean commitKeyUpdate_Fields_Addition(KeyWrapper keyWrapper) {
boolean hasChanges = false;
for (FieldWrapper eachField : keyWrapper.getFields()) {
if (!eachField.isUserCreated()) {
continue;
}
XSDXPathDefinition newXpath = XSDSchemaBuildingTools.getXSDFactory().createXSDXPathDefinition();
newXpath.setValue(eachField.getXPath());
newXpath.setVariety(XSDXPathVariety.FIELD_LITERAL);
keyWrapper.getSourceKey().getFields().add(newXpath);
keyWrapper.getSourceKey().updateElement();
hasChanges = true;
}
return hasChanges;
}
Aggregations