use of org.talend.core.model.metadata.builder.connection.Connection in project tdi-studio-se by Talend.
the class DynamicComposite method getRepositoryAliasName.
// /**
// * ftang Comment method "updateContextList".
// */
// public void updateContextList(IElementParameter jobParam) {
// if (jobParam == null || jobParam.getField() != EParameterFieldType.PROCESS_TYPE) {
// return;
// }
// // for context type
// List<String> contextNameList = new ArrayList<String>();
// List<String> contextValueList = new ArrayList<String>();
//
// IElementParameter jobNameParam =
// jobParam.getChildParameters().get(EParameterName.PROCESS_TYPE_PROCESS.getName());
//
// Item item = jobNameParam.getLinkedRepositoryItem();
// final String jobValue = (String) jobNameParam.getValue();
// if (jobValue != null) {
// if (item == null || (item != null && !item.getProperty().getId().equals(jobValue))) {
// item = ProcessorUtilities.getProcessItemById(jobValue);
// }
// } else {
// item = null;
// }
// if (item != null) {
// if (item instanceof ProcessItem) {
// for (Object o : ((ProcessItem) item).getProcess().getContext()) {
// if (o instanceof ContextType) {
// ContextType context = (ContextType) o;
// contextNameList.add(context.getName());
// contextValueList.add(context.getName());
// }
// }
// }
// jobNameParam.setLabelFromRepository(item.getProperty().getLabel());
// }
// jobNameParam.setLinkedRepositoryItem(item);
// // set default context
// String defalutValue = null;
// if (item != null && item instanceof ProcessItem) {
// defalutValue = ((ProcessItem) item).getProcess().getDefaultContext();
// }
// setProcessTypeRelatedValues(jobParam, contextNameList, contextValueList,
// EParameterName.PROCESS_TYPE_CONTEXT.getName(),
// defalutValue);
//
// // for version type
// List<String> versionNameList = new ArrayList<String>();
// List<String> versionValueList = new ArrayList<String>();
//
// if (item != null) { // existed item
// List<IRepositoryObject> allVersion = ProcessorUtilities.getAllRepositoryObjectById(item.getProperty().getId());
// for (IRepositoryObject obj : allVersion) {
// String version = obj.getVersion();
// versionNameList.add(version);
// versionValueList.add(version);
// }
// }
// setProcessTypeRelatedValues(jobParam, versionNameList, versionValueList,
// EParameterName.PROCESS_TYPE_VERSION.getName(),
// null);
//
// }
//
// /**
// *
// * ggu Comment method "setProcessTypeRelatedValues".
// *
// *
// */
// private void setProcessTypeRelatedValues(IElementParameter parentParam, List<String> nameList, List<String>
// valueList,
// final String childName, final String defaultValue) {
// if (parentParam == null || childName == null) {
// return;
// }
// final String fullChildName = parentParam.getName() + ":" + childName;
// IElementParameter childParam = parentParam.getChildParameters().get(childName);
// if (nameList == null) {
// childParam.setListItemsDisplayName(new String[0]);
// } else {
// childParam.setListItemsDisplayName(nameList.toArray(new String[0]));
// }
// if (valueList == null) {
// childParam.setListItemsValue(new String[0]);
// } else {
// childParam.setListItemsValue(valueList.toArray(new String[0]));
// }
// // set default value
// if (defaultValue != null) {
// childParam.setValue(defaultValue);
// }
// if (elem != null) {
// if (valueList != null && !valueList.contains(childParam.getValue())) {
// if (nameList != null && nameList.size() > 0) {
// elem.setPropertyValue(fullChildName, valueList.get(valueList.size() - 1));
// }
// } else {
// // force to store the value again to activate the code
// // generation in Node.setPropertyValue
// elem.setPropertyValue(fullChildName, childParam.getValue());
// }
// }
// }
public String getRepositoryAliasName(ConnectionItem connectionItem) {
ERepositoryObjectType repositoryObjectType = ERepositoryObjectType.getItemType(connectionItem);
String aliasName = repositoryObjectType.getAlias();
Connection connection = connectionItem.getConnection();
if (connection instanceof DatabaseConnection) {
//$NON-NLS-1$
String currentDbType = (String) RepositoryToComponentProperty.getValue(connection, "TYPE", null);
//$NON-NLS-1$ //$NON-NLS-2$
aliasName += " (" + currentDbType + ")";
}
return aliasName;
}
use of org.talend.core.model.metadata.builder.connection.Connection in project tdi-studio-se by Talend.
the class MultipleThreadDynamicComposite method updateRepositoryList.
public void updateRepositoryList() {
ProgressDialog progressDialog = new ProgressDialog(this.getShell(), 1000) {
private IProgressMonitor monitorWrap;
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
monitorWrap = new EventLoopProgressMonitor(monitor);
IProxyRepositoryFactory factory = DesignerPlugin.getDefault().getProxyRepositoryFactory();
List<IRepositoryViewObject> repositoryObjects = getAllRepositoryMetadata();
// + elem.getElementParameters().size();
int total = repositoryObjects.size();
//$NON-NLS-1$
monitorWrap.beginTask(Messages.getString("MultipleThreadDynamicComposite.gatherInformation"), total);
IElementParameter propertyParam = elem.getElementParameterFromField(EParameterFieldType.PROPERTY_TYPE, section);
String repositoryValue = null;
if (propertyParam != null) {
repositoryValue = propertyParam.getRepositoryValue();
}
if (repositoryObjects != null && (repositoryObjects.size() != 0)) {
tableIdAndDbTypeMap.clear();
tableIdAndDbSchemaMap.clear();
for (IRepositoryViewObject curObject : repositoryObjects) {
Item item = curObject.getProperty().getItem();
if (item instanceof ConnectionItem) {
ConnectionItem connectionItem = (ConnectionItem) item;
Connection connection = connectionItem.getConnection();
if (connection == null || connection.isReadOnly()) {
continue;
}
for (Object tableObj : ConnectionHelper.getTables(connection)) {
org.talend.core.model.metadata.builder.connection.MetadataTable table;
table = (org.talend.core.model.metadata.builder.connection.MetadataTable) tableObj;
if (factory.getStatus(connectionItem) != ERepositoryStatus.DELETED) {
if (!factory.isDeleted(table)) {
IMetadataTable newTable = ConvertionHelper.convert(table);
// newTable);
if (connection instanceof DatabaseConnection) {
String dbType = ((DatabaseConnection) connection).getDatabaseType();
String schema = ((DatabaseConnection) connection).getUiSchema();
tableIdAndDbTypeMap.put(newTable.getId(), dbType);
if (schema != null && !schema.equals("")) {
//$NON-NLS-1$
tableIdAndDbSchemaMap.put(newTable.getId(), schema);
}
}
}
}
}
monitorWrap.worked(1);
}
// hywang add for feature 6484
if (item instanceof FileItem) {
FileItem FileItem = (FileItem) item;
if (repositoryValue != null) {
if (repositoryValue.equals("RULE")) {
//$NON-NLS-1$
repositoryFileItemMap.put(FileItem.getProperty().getId(), FileItem);
}
}
monitorWrap.worked(1);
}
if (item instanceof LinkRulesItem) {
LinkRulesItem linkItem = (LinkRulesItem) item;
if (repositoryValue != null) {
if (repositoryValue.equals("RULE")) {
//$NON-NLS-1$
repositoryLinkRulesItemMap.put(linkItem.getProperty().getId(), linkItem);
}
}
monitorWrap.worked(1);
}
}
}
monitorWrap.done();
}
};
try {
progressDialog.executeProcess();
} catch (InvocationTargetException e) {
ExceptionHandler.process(e);
return;
} catch (Exception e) {
ExceptionHandler.process(e);
return;
}
}
use of org.talend.core.model.metadata.builder.connection.Connection in project tdi-studio-se by Talend.
the class JSONConnectionContextHelper method setPropertiesForContextMode.
public static void setPropertiesForContextMode(ConnectionItem connectionItem, ContextItem contextItem, Set<IConnParamName> paramSet, Map<String, String> map) {
if (connectionItem == null || contextItem == null) {
return;
}
final String label = contextItem.getProperty().getLabel();
Connection conn = connectionItem.getConnection();
if (conn instanceof JSONFileConnection) {
setJSONFilePropertiesForContextMode(label, (JSONFileConnection) conn);
}
// set connection for context mode
connectionItem.getConnection().setContextMode(true);
connectionItem.getConnection().setContextId(contextItem.getProperty().getId());
connectionItem.getConnection().setContextName(contextItem.getDefaultContext());
}
use of org.talend.core.model.metadata.builder.connection.Connection in project tdi-studio-se by Talend.
the class JSONConnectionContextHelper method revertPropertiesForContextMode.
public static void revertPropertiesForContextMode(ConnectionItem connItem, ContextType contextType) {
if (connItem == null || contextType == null) {
return;
}
Connection conn = connItem.getConnection();
if (conn instanceof JSONFileConnection) {
revertJSONFilePropertiesForContextMode((JSONFileConnection) conn, contextType);
}
// set connection for context mode
conn.setContextMode(false);
conn.setContextId(EMPTY);
}
use of org.talend.core.model.metadata.builder.connection.Connection in project tdi-studio-se by Talend.
the class FillParametersForDatabaseConnectionMigrationTask method execute.
@Override
public ExecutionResult execute(Item item) {
if (item instanceof DatabaseConnectionItem) {
DatabaseConnectionItem dbItem = (DatabaseConnectionItem) item;
Connection connection = dbItem.getConnection();
DatabaseConnection dbconn = (DatabaseConnection) connection;
EList<orgomg.cwm.objectmodel.core.Package> pkgs = dbconn.getDataPackage();
// get all tdtables and set sqldatatype
fillParametersForColumns(pkgs);
dbconn.setName(dbItem.getProperty().getLabel());
try {
factory.save(dbItem, true);
return ExecutionResult.SUCCESS_WITH_ALERT;
} catch (PersistenceException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
return ExecutionResult.SUCCESS_NO_ALERT;
}
Aggregations