use of org.eclipse.xsd.XSDComplexTypeDefinition 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.XSDComplexTypeDefinition in project tmdm-studio-se by Talend.
the class NewConceptOrElementDialog method validateType.
private void validateType(String typeName, boolean forConcept) {
getButton(IDialogConstants.OK_ID).setEnabled(true);
// $NON-NLS-1$
infoLabel.setText("");
for (XSDTypeDefinition specType : schema.getTypeDefinitions()) {
if (forConcept && specType instanceof XSDSimpleTypeDefinition) {
continue;
} else if (!forConcept && specType instanceof XSDComplexTypeDefinition) {
continue;
}
String typeToCompare = typeName;
// $NON-NLS-1$
int delimiter = typeToCompare.indexOf(" : ");
if (delimiter != -1) {
typeToCompare = typeToCompare.substring(0, delimiter);
}
if (typeToCompare.equals(specType.getName())) {
infoLabel.setText(Messages.NewConceptOrElementDialog_SameTypeNameAlreadyExists);
getButton(IDialogConstants.OK_ID).setEnabled(false);
return;
}
}
}
use of org.eclipse.xsd.XSDComplexTypeDefinition in project tmdm-studio-se by Talend.
the class Util method getChildElements.
public static Map<String, XSDParticle> getChildElements(String parentxpath, XSDComplexTypeDefinition ctype, boolean onlyTopLevel, final Set<Object> visited) throws Exception {
if (visited == null || ctype == null) {
throw new IllegalArgumentException();
}
if (parentxpath == null) {
// $NON-NLS-1$
parentxpath = "";
}
Map<String, XSDParticle> childElements = new HashMap<String, XSDParticle>();
XSDTypeDefinition baseType = ctype.getBaseType();
if (!visited.contains(ctype)) {
visited.add(ctype);
if (baseType instanceof XSDComplexTypeDefinition && baseType != ctype) {
XSDComplexTypeDefinition cmpType = (XSDComplexTypeDefinition) baseType;
childElements.putAll(getChildElements(parentxpath, cmpType, onlyTopLevel, visited));
}
childElements.putAll(getComplexChilds(parentxpath, ctype, onlyTopLevel, visited));
}
return childElements;
}
use of org.eclipse.xsd.XSDComplexTypeDefinition in project tmdm-studio-se by Talend.
the class Util method getComplexTypes.
public static List<XSDComplexTypeDefinition> getComplexTypes(XSDSchema xsd) {
EList<XSDTypeDefinition> contents = xsd.getTypeDefinitions();
List<XSDComplexTypeDefinition> complexs = new ArrayList<XSDComplexTypeDefinition>();
for (XSDTypeDefinition type : contents) {
if (type instanceof XSDComplexTypeDefinition) {
boolean exist = false;
for (XSDComplexTypeDefinition xsdEl : complexs) {
if (xsdEl.getName().equals(type.getName()) && xsdEl.getTargetNamespace() != null && type.getTargetNamespace() != null && xsdEl.getTargetNamespace().equals(type.getTargetNamespace())) {
exist = true;
break;
} else if (xsdEl.getTargetNamespace() == null && type.getTargetNamespace() == null && xsdEl.getName().equals(type.getName())) {
exist = true;
break;
}
}
if (!exist && ((type.getTargetNamespace() != null && !type.getTargetNamespace().equals(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001)) || type.getTargetNamespace() == null)) {
complexs.add((XSDComplexTypeDefinition) type);
}
}
}
return complexs;
}
use of org.eclipse.xsd.XSDComplexTypeDefinition 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 "";
}
Aggregations