use of org.eclipse.xsd.XSDElementDeclaration in project tmdm-studio-se by Talend.
the class Util method getTopElement.
public static String getTopElement(XSDElementDeclaration parent, XSDElementDeclaration son) {
XSDTypeDefinition type = parent.getTypeDefinition();
if (!(type instanceof XSDComplexTypeDefinition)) {
return null;
}
List<XSDComplexTypeDefinition> hierarchyComplexTypes = getAllSuperComplexTypes((XSDComplexTypeDefinition) type);
for (XSDComplexTypeDefinition complexType : hierarchyComplexTypes) {
if (complexType.getContent() instanceof XSDParticle) {
XSDParticle particle = (XSDParticle) complexType.getContent();
if (particle.getTerm() instanceof XSDModelGroup) {
XSDModelGroup group = (XSDModelGroup) particle.getTerm();
EList<XSDParticle> elist = group.getContents();
for (XSDParticle pt : elist) {
if (pt.getContent() instanceof XSDElementDeclaration) {
XSDElementDeclaration ele = (XSDElementDeclaration) pt.getContent();
if (ele == son) {
return ele.getName();
/*
* ArrayList<String> complexTypes = new ArrayList<String>(); XSDElementDeclaration spec
* = findOutSpecialSonElement( (XSDElementDeclaration) pt.getContent(), son,
* complexTypes); if (spec != null) return spec.getName();
*/
// if (ele.getTypeDefinition() instanceof XSDComplexTypeDefinition) {
//
// return ele.getName() + "/"//$NON-NLS-1$
// + getTopElement(ele, son, (XSDComplexTypeDefinition) ele.getTypeDefinition());
//
//
// }
}
}
}
}
}
}
// $NON-NLS-1$
return "";
}
use of org.eclipse.xsd.XSDElementDeclaration 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.XSDElementDeclaration 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.XSDElementDeclaration in project tmdm-studio-se by Talend.
the class Util method getConcepts.
public static List<String> getConcepts(XSDSchema schema) {
EList<XSDElementDeclaration> xsdElementDeclarations = schema.getElementDeclarations();
List<String> list = new ArrayList<String>();
for (XSDElementDeclaration el : xsdElementDeclarations.toArray(new XSDElementDeclaration[xsdElementDeclarations.size()])) {
if (!el.getIdentityConstraintDefinitions().isEmpty()) {
list.add(el.getName());
}
}
return list;
}
use of org.eclipse.xsd.XSDElementDeclaration in project tmdm-studio-se by Talend.
the class Util method getParent.
public static Object getParent(Object son) {
if (!((son instanceof XSDElementDeclaration) || (son instanceof XSDParticle))) {
return null;
}
XSDElementDeclaration elem = null;
if (son instanceof XSDParticle) {
elem = (XSDElementDeclaration) ((XSDParticle) son).getContent();
} else if (son instanceof XSDElementDeclaration) {
elem = (XSDElementDeclaration) son;
}
if (elem == null || elem.getSchema() == null) {
return null;
}
EList<XSDSchemaContent> parentList = elem.getSchema().getContents();
for (XSDSchemaContent top : parentList) {
if (!(top instanceof XSDElementDeclaration) && !(top instanceof XSDComplexTypeDefinition)) {
continue;
}
if (top instanceof XSDElementDeclaration) {
XSDElementDeclaration decl = (XSDElementDeclaration) top;
if (decl == son) {
return decl;
}
if (decl.getTypeDefinition() instanceof XSDComplexTypeDefinition) {
XSDComplexTypeDefinition type = (XSDComplexTypeDefinition) decl.getTypeDefinition();
if (type.getContent() instanceof XSDParticle) {
XSDParticle particle = (XSDParticle) type.getContent();
if (particle.getTerm() instanceof XSDModelGroup) {
XSDModelGroup group = (XSDModelGroup) particle.getTerm();
EList<XSDParticle> elist = group.getContents();
for (XSDParticle pt : elist) {
if (pt.getContent() instanceof XSDElementDeclaration) {
if (((XSDElementDeclaration) pt.getContent()) == elem) {
return decl;
}
}
Set<XSDConcreteComponent> complexTypes = new HashSet<XSDConcreteComponent>();
XSDElementDeclaration spec = findOutSpecialSonElement((XSDElementDeclaration) pt.getContent(), elem, complexTypes);
if (spec != null) {
return spec;
}
}
}
}
}
} else {
XSDComplexTypeDefinition type = (XSDComplexTypeDefinition) top;
if (type.getContent() instanceof XSDParticle) {
XSDParticle particle = (XSDParticle) type.getContent();
if (particle.getTerm() instanceof XSDModelGroup) {
XSDModelGroup group = (XSDModelGroup) particle.getTerm();
EList<XSDParticle> elist = group.getContents();
for (XSDParticle pt : elist) {
if (pt.getContent() instanceof XSDElementDeclaration) {
if (((XSDElementDeclaration) pt.getContent()) == elem) {
return top;
}
}
if (pt.getContent() instanceof XSDElementDeclaration) {
Set<XSDConcreteComponent> complexTypes = new HashSet<XSDConcreteComponent>();
XSDElementDeclaration spec = findOutSpecialSonElement((XSDElementDeclaration) pt.getContent(), elem, complexTypes);
if (spec != null) {
return spec;
}
}
}
}
}
}
}
return null;
}
Aggregations