use of org.eclipse.xsd.XSDIdentityConstraintDefinition in project tmdm-studio-se by Talend.
the class XSDChangeToComplexTypeAction method createUniqueKey.
private void createUniqueKey(XSDFactory factory, XSDElementDeclaration declaration, XSDComplexTypeDefinition complexType) {
List<String> fields = getPKFields(complexType);
if (!fields.isEmpty()) {
XSDIdentityConstraintDefinition uniqueKey = factory.createXSDIdentityConstraintDefinition();
uniqueKey.setIdentityConstraintCategory(XSDIdentityConstraintCategory.UNIQUE_LITERAL);
uniqueKey.setName(declaration.getName());
XSDXPathDefinition selector = factory.createXSDXPathDefinition();
selector.setVariety(XSDXPathVariety.SELECTOR_LITERAL);
// $NON-NLS-1$
selector.setValue(".");
uniqueKey.setSelector(selector);
for (String fieldName : fields) {
XSDXPathDefinition field = factory.createXSDXPathDefinition();
field.setVariety(XSDXPathVariety.FIELD_LITERAL);
field.setValue(fieldName);
uniqueKey.getFields().add(field);
}
declaration.getIdentityConstraintDefinitions().add(uniqueKey);
}
}
Aggregations