use of org.eclipse.xsd.XSDTerm in project tmdm-studio-se by Talend.
the class DOMViewDialog method collectKeyWords.
private void collectKeyWords(XSDElementDeclaration elementDeclaration, Set<String> keys) {
String elementName = elementDeclaration.getName();
keys.add(elementName);
XSDTypeDefinition typeDefinition = elementDeclaration.getType();
if (typeDefinition instanceof XSDComplexTypeDefinition) {
XSDParticle particle = (XSDParticle) ((XSDComplexTypeDefinition) typeDefinition).getContent();
XSDTerm term = particle.getTerm();
if (term instanceof XSDModelGroup) {
EList<XSDParticle> particles = ((XSDModelGroup) term).getContents();
for (XSDParticle p : particles) {
XSDTerm childTerm = p.getTerm();
if (childTerm instanceof XSDElementDeclaration) {
collectKeyWords((XSDElementDeclaration) childTerm, keys);
}
}
}
}
}
use of org.eclipse.xsd.XSDTerm in project tmdm-studio-se by Talend.
the class Util method getRealKeyInfos.
public static List<Object> getRealKeyInfos(XSDElementDeclaration currentEntity, XSDParticle son) {
if (currentEntity == null || son == null) {
return null;
}
if (!isDirectChild(currentEntity, son)) {
return null;
}
List<Object> list = new ArrayList<Object>();
XSDTerm term = son.getTerm();
if (term instanceof XSDElementDeclaration) {
String primaryKey = ((XSDElementDeclaration) term).getName();
EList<XSDIdentityConstraintDefinition> idtylist = currentEntity.getIdentityConstraintDefinitions();
for (XSDIdentityConstraintDefinition idty : idtylist) {
EList<XSDXPathDefinition> fields = idty.getFields();
for (XSDXPathDefinition path : fields) {
if ((path.getValue()).equals(primaryKey)) {
list.add(idty);
list.add(path);
break;
}
}
}
}
return list;
}
use of org.eclipse.xsd.XSDTerm in project tmdm-studio-se by Talend.
the class Util method updateReference.
public static void updateReference(Object decl, Object[] objs, Object[] allForeignKeyAndInfos, String oldValue, String newValue) {
if (!(decl instanceof XSDElementDeclaration)) {
return;
}
updatePrimaryKeyInfo((XSDElementDeclaration) decl, oldValue, newValue);
updateForeignKeyRelatedInfo(oldValue, newValue, allForeignKeyAndInfos);
for (Object obj : objs) {
if (obj instanceof XSDParticle) {
XSDTerm term = ((XSDParticle) obj).getTerm();
if (term instanceof XSDElementDeclaration) {
XSDElementDeclaration xsdElem = (XSDElementDeclaration) term;
if (xsdElem == decl) {
((XSDParticle) obj).setTerm((XSDElementDeclaration) decl);
((XSDParticle) obj).updateElement();
}
}
if (!(((XSDParticle) obj).getContent() instanceof XSDElementDeclaration)) {
continue;
}
XSDElementDeclaration elem = (XSDElementDeclaration) ((XSDParticle) obj).getContent();
if (elem.isElementDeclarationReference()) {
if (elem.getResolvedElementDeclaration() == decl) {
elem.setResolvedElementDeclaration((XSDElementDeclaration) decl);
}
}
}
}
}
use of org.eclipse.xsd.XSDTerm in project tmdm-studio-se by Talend.
the class XSDAnnotationsStructure method inputChanged.
protected void inputChanged(Object component) {
if (component instanceof XSDAnnotation) {
annotation = (XSDAnnotation) component;
if (annotation.getContainer() instanceof XSDElementDeclaration) {
declaration = (XSDElementDeclaration) annotation.getContainer();
} else if (annotation.getContainer() instanceof XSDComplexTypeDefinition) {
complexTypeDef = (XSDComplexTypeDefinition) annotation.getContainer();
}
}
if (component instanceof XSDElementDeclaration) {
declaration = (XSDElementDeclaration) component;
if (declaration.getAnnotation() == null) {
XSDFactory factory = XSDSchemaBuildingTools.getXSDFactory();
annotation = factory.createXSDAnnotation();
} else {
annotation = declaration.getAnnotation();
}
}
if (component instanceof XSDComplexTypeDefinition) {
complexTypeDef = (XSDComplexTypeDefinition) component;
componet = complexTypeDef;
if (complexTypeDef.getAnnotation() == null) {
XSDFactory factory = XSDSchemaBuildingTools.getXSDFactory();
annotation = factory.createXSDAnnotation();
} else {
annotation = complexTypeDef.getAnnotation();
}
}
if (component instanceof XSDModelGroup) {
XSDModelGroup group = (XSDModelGroup) component;
if (group.getContainer().getContainer() instanceof XSDComplexTypeDefinition) {
complexTypeDef = (XSDComplexTypeDefinition) group.getContainer().getContainer();
if (complexTypeDef.getAnnotation() == null) {
XSDFactory factory = XSDSchemaBuildingTools.getXSDFactory();
annotation = factory.createXSDAnnotation();
} else {
annotation = complexTypeDef.getAnnotation();
}
}
}
if (component instanceof XSDParticle) {
XSDTerm term = ((XSDParticle) component).getTerm();
if (term instanceof XSDElementDeclaration) {
declaration = (XSDElementDeclaration) term;
if (declaration.getAnnotation() == null) {
XSDFactory factory = XSDSchemaBuildingTools.getXSDFactory();
annotation = factory.createXSDAnnotation();
} else {
annotation = declaration.getAnnotation();
}
}
}
}
use of org.eclipse.xsd.XSDTerm in project tmdm-studio-se by Talend.
the class XSDUtil method isSimpleTypeElement.
public static boolean isSimpleTypeElement(XSDParticle particle) {
XSDTerm term = particle.getTerm();
if (term instanceof XSDElementDeclaration) {
XSDElementDeclaration element = ((XSDElementDeclaration) term);
XSDTypeDefinition type = element.getType();
if (type instanceof XSDSimpleTypeDefinition) {
return true;
}
}
return false;
}
Aggregations