Search in sources :

Example 1 with XSDTerm

use of org.eclipse.xsd.XSDTerm 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);
                }
            }
        }
    }
}
Also used : 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) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition)

Example 2 with XSDTerm

use of org.eclipse.xsd.XSDTerm 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;
}
Also used : XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) ArrayList(java.util.ArrayList) XSDTerm(org.eclipse.xsd.XSDTerm) XSDIdentityConstraintDefinition(org.eclipse.xsd.XSDIdentityConstraintDefinition) XObject(com.sun.org.apache.xpath.internal.objects.XObject) TreeObject(com.amalto.workbench.models.TreeObject) EObject(org.eclipse.emf.ecore.EObject) XSDXPathDefinition(org.eclipse.xsd.XSDXPathDefinition)

Example 3 with XSDTerm

use of org.eclipse.xsd.XSDTerm 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);
                }
            }
        }
    }
}
Also used : XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) XSDTerm(org.eclipse.xsd.XSDTerm) XObject(com.sun.org.apache.xpath.internal.objects.XObject) TreeObject(com.amalto.workbench.models.TreeObject) EObject(org.eclipse.emf.ecore.EObject) XSDParticle(org.eclipse.xsd.XSDParticle)

Example 4 with XSDTerm

use of org.eclipse.xsd.XSDTerm in project tmdm-studio-se by Talend.

the class XSDAnnotationsStructure method inputChanged.

protected void inputChanged(Object component) {
    if (component instanceof XSDAnnotation) {
        annotation = (XSDAnnotation) component;
        if (annotation.getContainer() instanceof XSDElementDeclaration) {
            declaration = (XSDElementDeclaration) annotation.getContainer();
        } else if (annotation.getContainer() instanceof XSDComplexTypeDefinition) {
            complexTypeDef = (XSDComplexTypeDefinition) annotation.getContainer();
        }
    }
    if (component instanceof XSDElementDeclaration) {
        declaration = (XSDElementDeclaration) component;
        if (declaration.getAnnotation() == null) {
            XSDFactory factory = XSDSchemaBuildingTools.getXSDFactory();
            annotation = factory.createXSDAnnotation();
        } else {
            annotation = declaration.getAnnotation();
        }
    }
    if (component instanceof XSDComplexTypeDefinition) {
        complexTypeDef = (XSDComplexTypeDefinition) component;
        componet = complexTypeDef;
        if (complexTypeDef.getAnnotation() == null) {
            XSDFactory factory = XSDSchemaBuildingTools.getXSDFactory();
            annotation = factory.createXSDAnnotation();
        } else {
            annotation = complexTypeDef.getAnnotation();
        }
    }
    if (component instanceof XSDModelGroup) {
        XSDModelGroup group = (XSDModelGroup) component;
        if (group.getContainer().getContainer() instanceof XSDComplexTypeDefinition) {
            complexTypeDef = (XSDComplexTypeDefinition) group.getContainer().getContainer();
            if (complexTypeDef.getAnnotation() == null) {
                XSDFactory factory = XSDSchemaBuildingTools.getXSDFactory();
                annotation = factory.createXSDAnnotation();
            } else {
                annotation = complexTypeDef.getAnnotation();
            }
        }
    }
    if (component instanceof XSDParticle) {
        XSDTerm term = ((XSDParticle) component).getTerm();
        if (term instanceof XSDElementDeclaration) {
            declaration = (XSDElementDeclaration) term;
            if (declaration.getAnnotation() == null) {
                XSDFactory factory = XSDSchemaBuildingTools.getXSDFactory();
                annotation = factory.createXSDAnnotation();
            } else {
                annotation = declaration.getAnnotation();
            }
        }
    }
}
Also used : XSDFactory(org.eclipse.xsd.XSDFactory) XSDModelGroup(org.eclipse.xsd.XSDModelGroup) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) XSDTerm(org.eclipse.xsd.XSDTerm) XSDAnnotation(org.eclipse.xsd.XSDAnnotation) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDParticle(org.eclipse.xsd.XSDParticle)

Example 5 with XSDTerm

use of org.eclipse.xsd.XSDTerm in project tmdm-studio-se by Talend.

the class XSDUtil method isSimpleTypeElement.

public static boolean isSimpleTypeElement(XSDParticle particle) {
    XSDTerm term = particle.getTerm();
    if (term instanceof XSDElementDeclaration) {
        XSDElementDeclaration element = ((XSDElementDeclaration) term);
        XSDTypeDefinition type = element.getType();
        if (type instanceof XSDSimpleTypeDefinition) {
            return true;
        }
    }
    return false;
}
Also used : XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) XSDTerm(org.eclipse.xsd.XSDTerm) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition)

Aggregations

XSDTerm (org.eclipse.xsd.XSDTerm)36 XSDElementDeclaration (org.eclipse.xsd.XSDElementDeclaration)32 XSDParticle (org.eclipse.xsd.XSDParticle)31 XSDModelGroup (org.eclipse.xsd.XSDModelGroup)28 XSDComplexTypeDefinition (org.eclipse.xsd.XSDComplexTypeDefinition)21 XSDAnnotation (org.eclipse.xsd.XSDAnnotation)16 XSDTypeDefinition (org.eclipse.xsd.XSDTypeDefinition)13 XSDIdentityConstraintDefinition (org.eclipse.xsd.XSDIdentityConstraintDefinition)10 XSDSimpleTypeDefinition (org.eclipse.xsd.XSDSimpleTypeDefinition)10 TreeObject (com.amalto.workbench.models.TreeObject)9 ArrayList (java.util.ArrayList)9 EList (org.eclipse.emf.common.util.EList)9 XSDComplexTypeContent (org.eclipse.xsd.XSDComplexTypeContent)8 XSDWildcard (org.eclipse.xsd.XSDWildcard)8 XSDXPathDefinition (org.eclipse.xsd.XSDXPathDefinition)8 Iterator (java.util.Iterator)6 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)6 XSDAttributeGroupDefinition (org.eclipse.xsd.XSDAttributeGroupDefinition)6 Element (org.w3c.dom.Element)6 XSDAnnotationsStructure (com.amalto.workbench.utils.XSDAnnotationsStructure)5