Search in sources :

Example 96 with XSDComplexTypeDefinition

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;
}
Also used : ArrayList(java.util.ArrayList) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition)

Example 97 with XSDComplexTypeDefinition

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);
                        }
                    }
                }
            }
        }
    }
}
Also used : XSDComplexTypeContent(org.eclipse.xsd.XSDComplexTypeContent) XSDModelGroup(org.eclipse.xsd.XSDModelGroup) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) XSDTerm(org.eclipse.xsd.XSDTerm) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDParticle(org.eclipse.xsd.XSDParticle)

Example 98 with XSDComplexTypeDefinition

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;
}
Also used : XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDParticle(org.eclipse.xsd.XSDParticle) XSDSchema(org.eclipse.xsd.XSDSchema) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition)

Example 99 with XSDComplexTypeDefinition

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;
}
Also used : XSDComplexTypeContent(org.eclipse.xsd.XSDComplexTypeContent) XSDModelGroup(org.eclipse.xsd.XSDModelGroup) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) XSDParticleContent(org.eclipse.xsd.XSDParticleContent) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) NodeList(org.w3c.dom.NodeList) EList(org.eclipse.emf.common.util.EList) List(java.util.List) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDParticle(org.eclipse.xsd.XSDParticle)

Example 100 with XSDComplexTypeDefinition

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;
}
Also used : XSDComplexTypeContent(org.eclipse.xsd.XSDComplexTypeContent) XSDModelGroup(org.eclipse.xsd.XSDModelGroup) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) XSDParticleContent(org.eclipse.xsd.XSDParticleContent) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) NodeList(org.w3c.dom.NodeList) EList(org.eclipse.emf.common.util.EList) List(java.util.List) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDParticle(org.eclipse.xsd.XSDParticle) XSDSchema(org.eclipse.xsd.XSDSchema)

Aggregations

XSDComplexTypeDefinition (org.eclipse.xsd.XSDComplexTypeDefinition)162 XSDElementDeclaration (org.eclipse.xsd.XSDElementDeclaration)93 XSDModelGroup (org.eclipse.xsd.XSDModelGroup)76 XSDParticle (org.eclipse.xsd.XSDParticle)75 XSDTypeDefinition (org.eclipse.xsd.XSDTypeDefinition)66 XSDSimpleTypeDefinition (org.eclipse.xsd.XSDSimpleTypeDefinition)53 ArrayList (java.util.ArrayList)43 XSDSchema (org.eclipse.xsd.XSDSchema)37 Test (org.junit.Test)37 EList (org.eclipse.emf.common.util.EList)25 XSDConcreteComponent (org.eclipse.xsd.XSDConcreteComponent)25 XSDFactory (org.eclipse.xsd.XSDFactory)23 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)22 XSDIdentityConstraintDefinition (org.eclipse.xsd.XSDIdentityConstraintDefinition)21 XSDTerm (org.eclipse.xsd.XSDTerm)21 XSDAnnotation (org.eclipse.xsd.XSDAnnotation)20 XSDComplexTypeContent (org.eclipse.xsd.XSDComplexTypeContent)20 Iterator (java.util.Iterator)19 List (java.util.List)19 XSDAttributeGroupDefinition (org.eclipse.xsd.XSDAttributeGroupDefinition)16