use of org.eclipse.xsd.XSDComplexTypeDefinition in project tmdm-studio-se by Talend.
the class Util method getAllSuperComplexTypes.
/**
* contains childType itself
*/
public static List<XSDComplexTypeDefinition> getAllSuperComplexTypes(XSDComplexTypeDefinition childType) {
if (childType == null) {
return new ArrayList<XSDComplexTypeDefinition>();
}
XSDTypeDefinition rootType = childType.getRootType();
XSDTypeDefinition typeDefinition = childType;
List<XSDComplexTypeDefinition> hierarchyComplexTypes = new ArrayList<XSDComplexTypeDefinition>();
while (typeDefinition != null && typeDefinition instanceof XSDComplexTypeDefinition) {
hierarchyComplexTypes.add((XSDComplexTypeDefinition) typeDefinition);
if (typeDefinition.equals(rootType)) {
break;
}
typeDefinition = typeDefinition.getBaseType();
}
return hierarchyComplexTypes;
}
use of org.eclipse.xsd.XSDComplexTypeDefinition in project tmdm-studio-se by Talend.
the class Util method getforeignKeyOfElement.
/**
* set the list with foreign concept name of in the element
*
* @author ymli
* @param list
* @param element
*/
public static void getforeignKeyOfElement(Set<String> list, XSDElementDeclaration element) {
if (element != null) {
if (element.getAnnotation() != null) {
getForeignKeyofParcle(list, element.getAnnotation());
}
if (element.getTypeDefinition() instanceof XSDComplexTypeDefinition) {
XSDComplexTypeContent fromcomplexType = ((XSDComplexTypeDefinition) element.getTypeDefinition()).getContent();
if (fromcomplexType instanceof XSDParticle) {
XSDParticle particle = (XSDParticle) fromcomplexType;
if (particle.getTerm() instanceof XSDModelGroup) {
XSDModelGroup modelGroup = ((XSDModelGroup) particle.getTerm());
EList<XSDParticle> fromlist = modelGroup.getContents();
for (XSDParticle el : fromlist.toArray(new XSDParticle[fromlist.size()])) {
XSDTerm term = el.getTerm();
if (term instanceof XSDElementDeclaration) {
if (isReferrenced(element, (XSDElementDeclaration) term)) {
continue;
}
getforeignKeyOfElement(list, (XSDElementDeclaration) term);
}
}
}
}
}
}
}
use of org.eclipse.xsd.XSDComplexTypeDefinition in project tmdm-studio-se by Talend.
the class XSDAnnotationsStructure method setAutoExpand.
/**
**************************************************************************
* Auto Expand
* @throws Exception
***************************************************************************
*/
public boolean setAutoExpand(String value) throws Exception {
if (!(declaration.getTypeDefinition() instanceof XSDComplexTypeDefinition)) {
return false;
}
XSDSchema xsd = schema != null ? schema : declaration.getSchema();
// $NON-NLS-1$
String auto = "X_AutoExpand";
String xsdString = Util.nodeToString(xsd.getDocument().getDocumentElement());
ArrayList<Object> objs = Util.getAllComplexTypeChildren(declaration);
for (Object obj : objs) {
if (obj instanceof XSDElementDeclaration || obj instanceof XSDParticle) {
boolean isImported = false;
if (obj instanceof XSDParticle) {
XSDParticle particle = (XSDParticle) obj;
if (particle.getTerm() instanceof XSDElementDeclaration) {
XSDElementDeclaration decl = (XSDElementDeclaration) particle.getTerm();
if (Util.IsAImporedElement(decl, xsdString)) {
XSDTypeDefinition typeDef = decl.getTypeDefinition();
if (Util.IsAImporedElement(typeDef, xsdString)) {
isImported = true;
}
}
}
} else if (obj instanceof XSDElementDeclaration) {
XSDElementDeclaration decl = (XSDElementDeclaration) obj;
if (Util.IsAImporedElement(decl, xsdString)) {
isImported = true;
}
}
if (!isImported) {
XSDAnnotationsStructure annotion = new XSDAnnotationsStructure((XSDComponent) obj);
annotion.setAppInfo(auto, value, true);
}
}
}
return true;
}
use of org.eclipse.xsd.XSDComplexTypeDefinition in project tmdm-studio-se by Talend.
the class XSDUtil method isPrimaryKeyElement.
public static boolean isPrimaryKeyElement(XSDParticle particle) {
if (isSimpleTypeElement(particle)) {
Map<XSDElementDeclaration, List<XSDComplexTypeDefinition>> entityMapComplexTypes = buildEntityUsedComplexTypeMap((XSDSchema) particle.getRootContainer());
Iterator<XSDElementDeclaration> iterator = entityMapComplexTypes.keySet().iterator();
while (iterator.hasNext()) {
XSDElementDeclaration concept = iterator.next();
List<String> keyFields = getKeyFields(concept);
if (keyFields.contains(((XSDElementDeclaration) particle.getTerm()).getName())) {
List<XSDComplexTypeDefinition> ctypes = entityMapComplexTypes.get(concept);
for (XSDComplexTypeDefinition ctype : ctypes) {
XSDComplexTypeContent ctypeContent = ctype.getContent();
if (ctypeContent instanceof XSDParticle) {
XSDParticle typeParticle = (XSDParticle) ctypeContent;
XSDParticleContent particleContent = typeParticle.getContent();
if (particleContent instanceof XSDModelGroup) {
XSDModelGroup particleGroup = (XSDModelGroup) particleContent;
if (particleGroup.getContents().contains(particle)) {
return true;
}
}
}
}
}
}
}
return false;
}
use of org.eclipse.xsd.XSDComplexTypeDefinition in project tmdm-studio-se by Talend.
the class XSDUtil method isFirstLevelChild.
public static boolean isFirstLevelChild(XSDParticle particle) {
XSDSchema schema = (XSDSchema) particle.getRootContainer();
Map<XSDElementDeclaration, List<XSDComplexTypeDefinition>> entityMapComplexTypes = buildEntityUsedComplexTypeMap(schema);
Iterator<XSDElementDeclaration> iterator = entityMapComplexTypes.keySet().iterator();
while (iterator.hasNext()) {
XSDElementDeclaration concept = iterator.next();
List<XSDComplexTypeDefinition> ctypes = entityMapComplexTypes.get(concept);
for (XSDComplexTypeDefinition ctype : ctypes) {
XSDComplexTypeContent ctypeContent = ctype.getContent();
if (ctypeContent instanceof XSDParticle) {
XSDParticle typeParticle = (XSDParticle) ctypeContent;
XSDParticleContent particleContent = typeParticle.getContent();
if (particleContent instanceof XSDModelGroup) {
XSDModelGroup particleGroup = (XSDModelGroup) particleContent;
if (particleGroup.getContents().contains(particle)) {
return true;
}
}
}
}
}
return false;
}
Aggregations