use of org.eclipse.xsd.impl.XSDParticleImpl in project tmdm-studio-se by Talend.
the class XSDChangeToComplexTypeAction method getUsablePKFields.
private List<String> getUsablePKFields(XSDComplexTypeDefinition complexType, List<XSDElementDeclaration> elementDeclarations) {
List<String> fields = new ArrayList<String>();
List<String> definedPKs = new ArrayList<String>();
XSDComplexTypeDefinition rootType = (XSDComplexTypeDefinition) complexType.getRootType();
for (XSDElementDeclaration decla : elementDeclarations) {
if (decla.getTypeDefinition() instanceof XSDComplexTypeDefinition) {
XSDComplexTypeDefinition typeDefinition = (XSDComplexTypeDefinition) decla.getTypeDefinition();
XSDTypeDefinition arootType = typeDefinition.getRootTypeDefinition();
if (arootType == rootType) {
recordFields(decla, definedPKs);
}
}
}
if (definedPKs.size() > 0) {
List<XSDComplexTypeDefinition> allSuperComplexTypes = Util.getAllSuperComplexTypes(complexType);
for (int i = allSuperComplexTypes.size() - 1; i >= 0; i--) {
XSDComplexTypeDefinition cTypeDef = allSuperComplexTypes.get(i);
if (cTypeDef.getContent() instanceof XSDParticle) {
XSDParticleImpl particle = (XSDParticleImpl) cTypeDef.getContent();
if (particle.getTerm() instanceof XSDModelGroup) {
XSDModelGroup group = (XSDModelGroup) particle.getTerm();
EList<XSDParticle> particles = group.getParticles();
for (XSDParticle part : particles) {
if (part.getTerm() instanceof XSDElementDeclaration) {
XSDElementDeclaration xsdDecl = (XSDElementDeclaration) part.getTerm();
if (definedPKs.contains(xsdDecl.getName())) {
fields.add(xsdDecl.getName());
}
}
}
}
}
}
}
return fields;
}
Aggregations