use of org.talend.core.model.metadata.builder.connection.Concept in project tdi-studio-se by Talend.
the class ComponentChooseDialog method isMdmOutput.
private boolean isMdmOutput(RepositoryNode selectedNode, ConnectionItem connectionItem) {
boolean isMdmOutput = false;
if (connectionItem instanceof MDMConnectionItem) {
MDMConnectionItem mdmItem = (MDMConnectionItem) connectionItem;
final MDMConnection connection = (MDMConnection) mdmItem.getConnection();
final EList<Concept> schemas = connection.getSchemas();
final Object properties = selectedNode.getProperties(EProperties.LABEL);
Concept concept = null;
for (int i = 0; i < schemas.size(); i++) {
final String label = schemas.get(i).getLabel();
if (label != null && label.equals(properties)) {
concept = schemas.get(i);
break;
}
}
if (concept != null && MdmConceptType.OUTPUT.equals(concept.getConceptType())) {
isMdmOutput = true;
}
}
return isMdmOutput;
}
use of org.talend.core.model.metadata.builder.connection.Concept in project tdi-studio-se by Talend.
the class TalendDndHelper method filterNeededComponents.
public static List<IComponent> filterNeededComponents(Item item, RepositoryNode seletetedNode, ERepositoryObjectType type) {
EDatabaseComponentName name = EDatabaseComponentName.getCorrespondingComponentName(item, type);
List<IComponent> neededComponents = new ArrayList<IComponent>();
if (name == null) {
return neededComponents;
}
String productNameWanted = filterProductNameWanted(name, item);
boolean hl7Related = false;
boolean hl7Output = false;
if (item instanceof HL7ConnectionItem) {
hl7Related = true;
EList list = ((HL7Connection) ((HL7ConnectionItem) item).getConnection()).getRoot();
if (list != null && list.size() > 0) {
hl7Output = true;
}
}
// for mdm
MdmConceptType mdmType = null;
if (item instanceof MDMConnectionItem) {
MDMConnectionItem mdmItem = (MDMConnectionItem) item;
if (seletetedNode != null && seletetedNode.getObject() instanceof MetadataTableRepositoryObject) {
MetadataTableRepositoryObject object = (MetadataTableRepositoryObject) seletetedNode.getObject();
if (mdmItem.getConnection() instanceof MDMConnection) {
MDMConnection connection = (MDMConnection) mdmItem.getConnection();
for (Object obj : connection.getSchemas()) {
if (obj instanceof Concept && object.getLabel().equals(((Concept) obj).getLabel())) {
mdmType = ((Concept) obj).getConceptType();
}
}
}
}
}
Set<IComponent> components = ComponentsFactoryProvider.getInstance().getComponents();
EmfComponent emfComponent = null;
for (IComponent component : components) {
if (component instanceof EmfComponent) {
emfComponent = (EmfComponent) component;
String componentProductname = emfComponent.getRepositoryType();
boolean value = true;
if (type == ERepositoryObjectType.METADATA_CON_TABLE) {
if (emfComponent.getName().toUpperCase().endsWith(MAP)) {
value = false;
}
}
if (hl7Output && !component.getName().equals("tHL7Output")) {
//$NON-NLS-1$
value = false;
} else if (hl7Related && !hl7Output && !component.getName().equals("tHL7Input")) {
//$NON-NLS-N$ bug15632
value = false;
}
boolean flag = filterComponent(component, name, type);
if (((componentProductname != null && productNameWanted.endsWith(componentProductname)) && value) || flag) {
Pattern pattern = Pattern.compile("^.*oracle.*$", Pattern.CASE_INSENSITIVE);
if (pattern.matcher(name.getDBType()).matches() && (emfComponent.getName().equals("tAmazonOracleInput") || emfComponent.getName().equals("tAmazonOracleOutput"))) {
continue;
}
if (item instanceof MDMConnectionItem) {
if (MdmConceptType.INPUT.equals(mdmType) && emfComponent.getName().endsWith(INPUT)) {
neededComponents.add(emfComponent);
} else if (MdmConceptType.OUTPUT.equals(mdmType) && emfComponent.getName().endsWith(OUTPUT)) {
neededComponents.add(emfComponent);
} else if (MdmConceptType.RECEIVE.equals(mdmType) && emfComponent.getName().endsWith(RECEIVE)) {
neededComponents.add(emfComponent);
}
} else {
neededComponents.add(emfComponent);
}
}
}
}
return sortFilteredComponnents(item, seletetedNode, type, neededComponents);
}
use of org.talend.core.model.metadata.builder.connection.Concept in project tdi-studio-se by Talend.
the class MdmConceptMigrationTask method execute.
/*
* (non-Javadoc)
*
* @see org.talend.core.model.migration.AbstractItemMigrationTask#execute(org.talend.core.model.properties.Item)
*/
@Override
public ExecutionResult execute(Item item) {
if (item instanceof MDMConnectionItem) {
boolean modify = false;
MDMConnectionItem mdmConnItem = (MDMConnectionItem) item;
if (mdmConnItem.getConnection() instanceof MDMConnection) {
MDMConnection mdmConnection = (MDMConnection) mdmConnItem.getConnection();
final EList<Concept> schemas = mdmConnection.getSchemas();
for (Concept concept : schemas) {
if (!concept.isInputModel()) {
concept.setConceptType(MdmConceptType.OUTPUT);
modify = true;
}
}
}
if (modify) {
try {
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
factory.save(item, true);
return ExecutionResult.SUCCESS_WITH_ALERT;
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
}
return ExecutionResult.NOTHING_TO_DO;
}
use of org.talend.core.model.metadata.builder.connection.Concept in project tdi-studio-se by Talend.
the class ImportTreeFromRepository method prepareEmfTreeFromMdm.
private void prepareEmfTreeFromMdm(MDMConnection connection, String selectedConcept) throws Exception {
if (connection == null || selectedConcept == null) {
return;
}
EList<Concept> schemas = connection.getSchemas();
Concept selected = null;
for (int i = 0; i < schemas.size(); i++) {
Concept concept = schemas.get(i);
if (selectedConcept.equals(concept.getLabel())) {
selected = concept;
break;
}
}
if (selected != null) {
IMDMProviderService service = (IMDMProviderService) GlobalServiceRegister.getDefault().getService(IMDMProviderService.class);
if (service != null) {
boolean initConcepts = service.initConcepts(connection);
if (initConcepts) {
if (!MdmConceptType.OUTPUT.equals(selected.getConceptType())) {
String prefix = service.getXPathPrefixValue(selected);
prefix = TalendTextUtils.removeQuotes(prefix);
absoluteXPathQuery = selected.getLoopExpression();
EList<ConceptTarget> conceptTargets = selected.getConceptTargets();
if (conceptTargets == null || absoluteXPathQuery == null) {
return;
}
this.schemaTargets = conceptTargets;
// find corresponding metadata table
Set<MetadataTable> metadataTables = ConnectionHelper.getTables(connection);
for (MetadataTable table : metadataTables) {
if (selected.getLabel() != null && selected.getLabel().equals(table.getLabel())) {
metadataTable = table;
break;
}
}
List<FOXTreeNode> list = TreeUtil.getFoxTreeNodesForXmlMap(getTempTemplateXSDFile().getAbsolutePath(), absoluteXPathQuery, true);
TreeNode pNode = schemaNode;
if (MdmConceptType.RECEIVE.equals(selected.getConceptType())) {
List<FOXTreeNode> updateNodesList = TreeUtil.parseMDMUpdateReport(shell, true);
schemaNode.getChildren().clear();
if (updateNodesList == null) {
if (prefix != null && !"".equals(prefix)) {
String[] preValues = prefix.split(XmlMapUtil.XPATH_SEPARATOR);
for (String value : preValues) {
if (!"".equals(value)) {
TreeNode createTreeNode = createModel();
createTreeNode.setName(value);
createTreeNode.setNodeType(NodeType.ELEMENT);
createTreeNode.setType(XmlMapUtil.DEFAULT_DATA_TYPE);
createTreeNode.setXpath(XmlMapUtil.getXPath(pNode.getXpath(), createTreeNode.getName(), createTreeNode.getNodeType()));
pNode.getChildren().add(createTreeNode);
pNode = createTreeNode;
}
}
absoluteXPathQuery = prefix + absoluteXPathQuery;
}
} else {
//$NON-NLS-1$
TreeNode rootNode = createDefaultTreeNode(pNode, "exchange");
//$NON-NLS-1$
TreeNode reportNode = createDefaultTreeNode(rootNode, "report");
//$NON-NLS-1$
TreeNode itemNode = createDefaultTreeNode(rootNode, "item");
// parse the update content..
prepareEmfTree(updateNodesList, reportNode, true);
pNode = itemNode;
//$NON-NLS-1$
absoluteXPathQuery = "/exchange/item" + absoluteXPathQuery;
}
} else {
schemaNode.getChildren().clear();
}
prepareEmfTree(list, pNode);
} else {
List<FOXTreeNode> list = TreeUtil.getFoxTreeNodesForXmlMap(getTempTemplateXSDFile().getAbsolutePath(), selected.getRoot().get(0).getXMLPath(), true);
schemaNode.getChildren().clear();
root = selected.getRoot();
loop = selected.getLoop();
group = selected.getGroup();
groupElements = new ArrayList<TreeNode>();
prepareModelFromOutput(list, schemaNode);
if (loopNode != null) {
fillGroup(loopNode, groupElements);
} else {
if (!schemaNode.getChildren().isEmpty()) {
schemaNode.getChildren().get(0).setLoop(true);
}
}
}
}
}
}
}
Aggregations