Search in sources :

Example 31 with XSDIdentityConstraintDefinition

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

the class EntityCommitHandler method commitEntityName.

private boolean commitEntityName() {
    XSDElementDeclaration xsdElementDeclaration = getCommitedObj().getSourceEntity();
    String oldName = xsdElementDeclaration.getName();
    String newName = getCommitedObj().getName();
    if (oldName.equals(newName)) {
        return false;
    }
    xsdElementDeclaration.setName(newName);
    xsdElementDeclaration.updateElement();
    updateReferenceForNewName(xsdElementDeclaration, oldName);
    // to correct unique's name
    for (Object idConsObj : xsdElementDeclaration.getIdentityConstraintDefinitions()) {
        XSDIdentityConstraintDefinition idCons = (XSDIdentityConstraintDefinition) idConsObj;
        if (idCons.getName().equals(oldName)) {
            idCons.setName(newName);
            idCons.updateElement();
            break;
        }
    }
    if (mapinfoExAdapter != null) {
        mapinfoExAdapter.renameEntityMapinfo(oldName, newName);
    }
    if (elementExAdapter != null) {
        elementExAdapter.renameEntityName(xsdElementDeclaration.getSchema(), oldName, newName);
    }
    return true;
}
Also used : XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) XSDIdentityConstraintDefinition(org.eclipse.xsd.XSDIdentityConstraintDefinition)

Example 32 with XSDIdentityConstraintDefinition

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

the class EntityWrapper method init.

private void init() {
    if (sourceEntity != null) {
        name = sourceEntity.getName();
        for (XSDIdentityConstraintDefinition eachId : sourceEntity.getIdentityConstraintDefinitions()) {
            keys.add(new KeyWrapper(eachId));
        }
        nameValidator = new EditXSDEleDecNameValidator(sourceEntity.getSchema());
    }
}
Also used : XSDIdentityConstraintDefinition(org.eclipse.xsd.XSDIdentityConstraintDefinition) EditXSDEleDecNameValidator(com.amalto.workbench.utils.inputvalidator.EditXSDEleDecNameValidator)

Example 33 with XSDIdentityConstraintDefinition

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

the class AddBrowseItemsWizard method createNewTreeObject.

private TreeObject createNewTreeObject(XSDElementDeclaration decl, String browseItem) {
    WSView view = new WSView();
    view.setIsTransformerActive(new WSBoolean(false));
    // $NON-NLS-1$
    view.setTransformerPK("");
    view.setName(browseItem);
    EList<XSDIdentityConstraintDefinition> idtylist = decl.getIdentityConstraintDefinitions();
    List<String> keys = new ArrayList<String>();
    for (XSDIdentityConstraintDefinition idty : idtylist) {
        EList<XSDXPathDefinition> xpathList = idty.getFields();
        for (XSDXPathDefinition path : xpathList) {
            String key = decl.getName();
            // remove
            // $NON-NLS-1$//$NON-NLS-2$
            key = key.replaceFirst("#.*", "");
            // $NON-NLS-1$
            key += "/" + path.getValue();
            keys.add(key);
        }
    }
    view.getSearchableBusinessElements().addAll(keys);
    view.getViewableBusinessElements().addAll(keys);
    StringBuffer desc = new StringBuffer();
    LinkedHashMap<String, String> labels = new LinkedHashMap<String, String>();
    if (decl.getAnnotation() != null) {
        labels = new XSDAnnotationsStructure(decl.getAnnotation()).getLabels();
    }
    if (labels.size() == 0) {
        // $NON-NLS-1$
        labels.put("EN", decl.getName());
    }
    for (String lan : labels.keySet()) {
        // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
        desc.append("[" + lan.toUpperCase() + ":" + labels.get(lan) + "]");
    }
    view.setDescription(desc.toString());
    WSPutView wrap = new WSPutView();
    wrap.setWsView(view);
    WSViewPK viewPk = new WSViewPK();
    viewPk.setPk(browseItem);
    WSDeleteView delView = new WSDeleteView();
    delView.setWsViewPK(viewPk);
    WSGetView getView = new WSGetView();
    getView.setWsViewPK(viewPk);
    service.putView(wrap);
    // add node in the root
    TreeParent root = page.getXObject().getServerRoot();
    TreeObject obj = new // no storage to save
    TreeObject(// no storage to save
    browseItem, // no storage to save
    root, // no storage to save
    TreeObject.VIEW, // no storage to save
    viewPk, // no storage to save
    null);
    return obj;
}
Also used : XSDAnnotationsStructure(com.amalto.workbench.utils.XSDAnnotationsStructure) TreeParent(com.amalto.workbench.models.TreeParent) ArrayList(java.util.ArrayList) WSDeleteView(com.amalto.workbench.webservices.WSDeleteView) WSView(com.amalto.workbench.webservices.WSView) LinkedHashMap(java.util.LinkedHashMap) WSPutView(com.amalto.workbench.webservices.WSPutView) XSDIdentityConstraintDefinition(org.eclipse.xsd.XSDIdentityConstraintDefinition) TreeObject(com.amalto.workbench.models.TreeObject) WSBoolean(com.amalto.workbench.webservices.WSBoolean) XSDXPathDefinition(org.eclipse.xsd.XSDXPathDefinition) WSGetView(com.amalto.workbench.webservices.WSGetView) WSViewPK(com.amalto.workbench.webservices.WSViewPK)

Example 34 with XSDIdentityConstraintDefinition

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

the class TreeExpandHelper method getName.

private String getName(Object objA) {
    if (objA instanceof XSDElementDeclaration) {
        XSDElementDeclaration decl = (XSDElementDeclaration) objA;
        return decl.getName();
    }
    if (objA instanceof XSDModelGroup) {
        XSDModelGroup goup = (XSDModelGroup) objA;
        XSDParticle particle = (XSDParticle) goup.getContainer();
        XSDComplexTypeDefinition complexTypeDefinition = (XSDComplexTypeDefinition) particle.getContainer();
        String name = complexTypeDefinition.getName();
        return name;
    }
    if (objA instanceof XSDModelGroupDefinition) {
        XSDModelGroupDefinition goupDef = (XSDModelGroupDefinition) objA;
        return goupDef.getName();
    }
    if (objA instanceof XSDParticle) {
        XSDParticle particle = (XSDParticle) objA;
        if (particle.getTerm() instanceof XSDElementDeclaration) {
            XSDElementDeclaration decl = (XSDElementDeclaration) particle.getTerm();
            return decl.getName();
        }
    }
    if (objA instanceof XSDAnnotation) {
        return null;
    }
    if (objA instanceof XSDIdentityConstraintDefinition) {
        XSDIdentityConstraintDefinition constraint = (XSDIdentityConstraintDefinition) objA;
        return constraint.getName();
    }
    if (objA instanceof XSDSimpleTypeDefinition) {
        XSDSimpleTypeDefinition simpleDefine = (XSDSimpleTypeDefinition) objA;
        return simpleDefine.getName();
    }
    if (objA instanceof XSDComplexTypeDefinition) {
        XSDComplexTypeDefinition complexDefine = (XSDComplexTypeDefinition) objA;
        return complexDefine.getName();
    }
    return null;
}
Also used : XSDModelGroup(org.eclipse.xsd.XSDModelGroup) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) XSDIdentityConstraintDefinition(org.eclipse.xsd.XSDIdentityConstraintDefinition) XSDModelGroupDefinition(org.eclipse.xsd.XSDModelGroupDefinition) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDAnnotation(org.eclipse.xsd.XSDAnnotation) XSDParticle(org.eclipse.xsd.XSDParticle)

Example 35 with XSDIdentityConstraintDefinition

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

the class XSDEditor method resetTreeSelection.

private void resetTreeSelection(int newPageIndex) {
    DataModelMainPage dataModelEditorPage = getDataModelEditorPage();
    if (dataModelEditorPage != null) {
        TreeViewer treeViewer = dataModelEditorPage.getTreeViewer();
        if (newPageIndex == MODEL_PAGE_INDEX) {
            treeViewer.setSelection(null);
        } else if (newPageIndex == SOURCE_PAGE_INDEX) {
            IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();
            if (!selection.isEmpty()) {
                Object firstElement = selection.getFirstElement();
                if ((firstElement instanceof XSDIdentityConstraintDefinition)) {
                    XSDIdentityConstraintDefinition cdf = (XSDIdentityConstraintDefinition) firstElement;
                    XSDConcreteComponent container = cdf.getContainer();
                    treeViewer.setSelection(new StructuredSelection(container));
                } else if ((firstElement instanceof XSDXPathDefinition)) {
                    XSDXPathDefinition pathdef = (XSDXPathDefinition) firstElement;
                    XSDConcreteComponent container = pathdef.getContainer().getContainer();
                    treeViewer.setSelection(new StructuredSelection(container));
                } else if (firstElement instanceof XSDAnnotation) {
                    XSDAnnotation annotation = (XSDAnnotation) firstElement;
                    XSDConcreteComponent container = annotation.getContainer();
                    treeViewer.setSelection(new StructuredSelection(container));
                }
            }
        }
    }
}
Also used : XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) TreeViewer(org.eclipse.jface.viewers.TreeViewer) DataModelMainPage(com.amalto.workbench.editors.DataModelMainPage) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) XSDIdentityConstraintDefinition(org.eclipse.xsd.XSDIdentityConstraintDefinition) EObject(org.eclipse.emf.ecore.EObject) TreeObject(com.amalto.workbench.models.TreeObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) XSDXPathDefinition(org.eclipse.xsd.XSDXPathDefinition) XSDAnnotation(org.eclipse.xsd.XSDAnnotation)

Aggregations

XSDIdentityConstraintDefinition (org.eclipse.xsd.XSDIdentityConstraintDefinition)56 XSDElementDeclaration (org.eclipse.xsd.XSDElementDeclaration)38 XSDXPathDefinition (org.eclipse.xsd.XSDXPathDefinition)32 XSDComplexTypeDefinition (org.eclipse.xsd.XSDComplexTypeDefinition)21 ArrayList (java.util.ArrayList)20 XSDParticle (org.eclipse.xsd.XSDParticle)19 XSDModelGroup (org.eclipse.xsd.XSDModelGroup)18 XSDSimpleTypeDefinition (org.eclipse.xsd.XSDSimpleTypeDefinition)18 Iterator (java.util.Iterator)15 XSDTypeDefinition (org.eclipse.xsd.XSDTypeDefinition)14 XSDAnnotation (org.eclipse.xsd.XSDAnnotation)13 XSDAttributeGroupDefinition (org.eclipse.xsd.XSDAttributeGroupDefinition)13 XSDFactory (org.eclipse.xsd.XSDFactory)13 XSDSchema (org.eclipse.xsd.XSDSchema)13 EList (org.eclipse.emf.common.util.EList)12 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)11 XSDAttributeDeclaration (org.eclipse.xsd.XSDAttributeDeclaration)10 XSDTerm (org.eclipse.xsd.XSDTerm)10 Element (org.w3c.dom.Element)10 TreeObject (com.amalto.workbench.models.TreeObject)9