Search in sources :

Example 1 with FieldWrapper

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);
    }
}
Also used : FieldWrapper(com.amalto.workbench.detailtabs.sections.model.entity.FieldWrapper)

Example 2 with FieldWrapper

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;
}
Also used : KeyWrapper(com.amalto.workbench.detailtabs.sections.model.entity.KeyWrapper) XSDFactory(org.eclipse.xsd.XSDFactory) XSDIdentityConstraintDefinition(org.eclipse.xsd.XSDIdentityConstraintDefinition) FieldWrapper(com.amalto.workbench.detailtabs.sections.model.entity.FieldWrapper) XSDXPathDefinition(org.eclipse.xsd.XSDXPathDefinition)

Example 3 with FieldWrapper

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;
}
Also used : FieldWrapper(com.amalto.workbench.detailtabs.sections.model.entity.FieldWrapper)

Example 4 with FieldWrapper

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]);
}
Also used : ArrayList(java.util.ArrayList) FieldWrapper(com.amalto.workbench.detailtabs.sections.model.entity.FieldWrapper) XSDXPathDefinition(org.eclipse.xsd.XSDXPathDefinition)

Example 5 with FieldWrapper

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;
}
Also used : FieldWrapper(com.amalto.workbench.detailtabs.sections.model.entity.FieldWrapper) XSDXPathDefinition(org.eclipse.xsd.XSDXPathDefinition)

Aggregations

FieldWrapper (com.amalto.workbench.detailtabs.sections.model.entity.FieldWrapper)5 XSDXPathDefinition (org.eclipse.xsd.XSDXPathDefinition)3 KeyWrapper (com.amalto.workbench.detailtabs.sections.model.entity.KeyWrapper)1 ArrayList (java.util.ArrayList)1 XSDFactory (org.eclipse.xsd.XSDFactory)1 XSDIdentityConstraintDefinition (org.eclipse.xsd.XSDIdentityConstraintDefinition)1