use of org.eclipse.xsd.XSDXPathDefinition 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;
}
use of org.eclipse.xsd.XSDXPathDefinition in project tmdm-studio-se by Talend.
the class XSDUtil method getKeyFields.
public static List<String> getKeyFields(XSDElementDeclaration concept) {
List<String> keyFields = new ArrayList<String>();
EList<XSDIdentityConstraintDefinition> identityConstraintDefinitions = concept.getIdentityConstraintDefinitions();
for (XSDIdentityConstraintDefinition icd : identityConstraintDefinitions) {
if (concept.getName().equals(icd.getName())) {
EList<XSDXPathDefinition> fields = icd.getFields();
for (XSDXPathDefinition xpathdef : fields) {
keyFields.add(xpathdef.getValue());
}
}
}
return keyFields;
}
use of org.eclipse.xsd.XSDXPathDefinition in project tmdm-studio-se by Talend.
the class Util method getTopParent.
public static List<Object> getTopParent(Object son) {
if (!((son instanceof XSDElementDeclaration))) {
return null;
}
XSDElementDeclaration elem = null;
elem = (XSDElementDeclaration) son;
if (elem.getSchema() == null) {
return null;
}
EList<XSDSchemaContent> parentList = elem.getSchema().getContents();
List<Object> list = new ArrayList<Object>();
for (XSDSchemaContent top : parentList) {
list.clear();
if (!(top instanceof XSDElementDeclaration)) {
continue;
}
XSDElementDeclaration decl = (XSDElementDeclaration) top;
if (decl.getTypeDefinition() instanceof XSDComplexTypeDefinition) {
String primaryKey = getTopElement(decl, elem);
if (!"".equalsIgnoreCase(primaryKey)) {
// $NON-NLS-1$
EList<XSDIdentityConstraintDefinition> idtylist = decl.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);
return list;
}
}
}
}
}
}
return null;
}
use of org.eclipse.xsd.XSDXPathDefinition in project tmdm-studio-se by Talend.
the class RepositoryResourceUtil method getBusinessConceptKey.
public static WSConceptKey getBusinessConceptKey(WSGetBusinessConceptKey businessConcepKey) throws XtentisException {
String pk = businessConcepKey.getWsDataModelPK().getPk();
String concept = businessConcepKey.getConcept();
WSDataModelE dataModel = RepositoryQueryService.findDataModelByName(pk);
if (dataModel != null) {
try {
XSDSchema xsdSchema = Util.getXSDSchema(dataModel.getXsdSchema());
for (XSDIdentityConstraintDefinition idDef : xsdSchema.getIdentityConstraintDefinitions()) {
if (idDef.getName().equals(concept)) {
WSConceptKey key = new WSConceptKey();
//
XSDXPathDefinition selector = idDef.getSelector();
key.setSelector(selector.getValue());
//
EList<XSDXPathDefinition> fields = idDef.getFields();
List<String> keyFields = new ArrayList<String>();
for (XSDXPathDefinition pathDef : fields) {
keyFields.add(pathDef.getValue());
}
key.getFields().clear();
key.getFields().addAll(keyFields);
return key;
}
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
return null;
}
use of org.eclipse.xsd.XSDXPathDefinition in project tmdm-studio-se by Talend.
the class XSDDeleteConceptWrapAction method doAction.
@Override
public IStatus doAction() {
List<IStatus> results = new ArrayList<IStatus>();
try {
IStructuredSelection selection = (IStructuredSelection) page.getTreeViewer().getSelection();
if (delObjs.isEmpty()) {
return Status.CANCEL_STATUS;
} else {
boolean sameType = checkInSameClassType(delObjs.toArray(), delObjs.get(0).getClass());
String deleteLabel = Messages.DelLabel1;
String elemDesc = ((Action) clsAction.get(delObjs.get(0).getClass())).getText();
// $NON-NLS-1$
int backPos = elemDesc.indexOf(" ");
if (delObjs.size() > 1) {
deleteLabel += elemDesc.substring(0, backPos) + Messages.DelLabel2 + delObjs.size() + Messages.DelLabel2A + (!sameType ? Messages.DelLabel2B : elemDesc.substring(backPos + 1));
if (deleteLabel.endsWith("y")) {
// $NON-NLS-1$
deleteLabel = deleteLabel.substring(0, deleteLabel.length() - 1) + Messages.DelLabel3;
} else {
deleteLabel = deleteLabel + Messages.XSDDeleteXX_DelLabel4;
}
} else {
deleteLabel += elemDesc.substring(0, backPos) + Messages.XSDDeleteXX_DelLabel5 + (!sameType ? Messages.XSDDeleteXX_DelLabel5A : elemDesc.substring(backPos + 1));
}
if (!MessageDialog.openConfirm(page.getSite().getShell(), Messages.XSDDeleteXX_DialogTitle, deleteLabel)) {
return Status.CANCEL_STATUS;
}
}
for (Iterator iterator = delObjs.iterator(); iterator.hasNext(); ) {
Object toDel = iterator.next();
UndoAction delExecute = null;
boolean isElem = true;
if (toDel instanceof XSDElementDeclaration) {
XSDElementDeclaration decl = (XSDElementDeclaration) toDel;
EList l = decl.getIdentityConstraintDefinitions();
for (Iterator iter = l.iterator(); iter.hasNext(); ) {
XSDIdentityConstraintDefinition icd = (XSDIdentityConstraintDefinition) iter.next();
if (icd.getIdentityConstraintCategory().equals(XSDIdentityConstraintCategory.UNIQUE_LITERAL)) {
isElem = false;
break;
}
}
}
if (toDel instanceof XSDXPathDefinition) {
XSDXPathDefinition xpath = (XSDXPathDefinition) toDel;
if (!xpath.getVariety().equals(XSDXPathVariety.FIELD_LITERAL)) {
continue;
}
}
delExecute = clsAction.get(toDel.getClass());
if (isElem && toDel instanceof XSDElementDeclaration) {
delExecute = clsAction.get(null);
}
if (delExecute instanceof XSDDeleteConceptAction && toDel instanceof XSDElementDeclaration) {
((XSDDeleteConceptAction) delExecute).setXSDTODel((XSDElementDeclaration) toDel);
} else if (delExecute instanceof XSDDeleteElementAction && toDel instanceof XSDElementDeclaration) {
((XSDDeleteElementAction) delExecute).setXSDTODel((XSDElementDeclaration) toDel);
} else if (delExecute instanceof XSDDeleteParticleAction && toDel instanceof XSDParticle) {
((XSDDeleteParticleAction) delExecute).setXSDTODel((XSDParticle) toDel);
} else if (delExecute instanceof XSDDeleteXPathAction && toDel instanceof XSDXPathDefinition) {
((XSDDeleteXPathAction) delExecute).setXSDTODel((XSDXPathDefinition) toDel);
} else if (delExecute instanceof XSDDeleteIdentityConstraintAction && toDel instanceof XSDIdentityConstraintDefinition) {
((XSDDeleteIdentityConstraintAction) delExecute).setXSDTODel((XSDIdentityConstraintDefinition) toDel);
} else if (delExecute instanceof XSDDeleteTypeDefinition && toDel instanceof XSDComplexTypeDefinition) {
((XSDDeleteTypeDefinition) delExecute).setXSDTODel((XSDComplexTypeDefinition) toDel);
} else if (delExecute instanceof XSDDeleteTypeDefinition && toDel instanceof XSDSimpleTypeDefinition) {
((XSDDeleteTypeDefinition) delExecute).setXSDTODel((XSDSimpleTypeDefinition) toDel);
} else if (delExecute instanceof XSDDeleteAttributeAction && toDel instanceof XSDAttributeUse) {
((XSDDeleteAttributeAction) delExecute).setXSDAttributeUse((XSDAttributeUse) toDel);
} else if (delExecute instanceof XSDDeleteAttributeAction && toDel instanceof XSDAttributeDeclaration) {
((XSDDeleteAttributeAction) delExecute).setXSDAttribute((XSDAttributeDeclaration) toDel);
} else {
return Status.CANCEL_STATUS;
}
results.add(delExecute.execute());
}
} catch (Exception e) {
log.error(e.getMessage(), e);
MessageDialog.openError(page.getSite().getShell(), Messages._Error, Messages.bind(Messages.XSDDeleteXX_ErrorMsg, e.getLocalizedMessage()));
return (results.indexOf(Status.OK_STATUS) >= 0 ? Status.OK_STATUS : Status.CANCEL_STATUS);
}
return (results.indexOf(Status.OK_STATUS) >= 0 ? Status.OK_STATUS : Status.CANCEL_STATUS);
}
Aggregations