use of org.talend.core.model.repository.IRepositoryViewObject 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.repository.IRepositoryViewObject in project tdi-studio-se by Talend.
the class MultipleThreadDynamicComposite method getAllRepositoryMetadata.
/**
*
* cli Comment method "getAllRepositoryMetadata".
*
* fixed for 8971
*/
private List<IRepositoryViewObject> getAllRepositoryMetadata() {
IProxyRepositoryFactory factory = DesignerPlugin.getDefault().getProxyRepositoryFactory();
ProjectManager pManager = ProjectManager.getInstance();
// retrieve reference project.
pManager.getReferencedProjects();
List<IRepositoryViewObject> repositoryObjects;
try {
repositoryObjects = retrieveMetadataFromProject(factory, pManager, pManager.getCurrentProject());
} catch (PersistenceException e) {
throw new RuntimeException(e);
}
return repositoryObjects;
}
use of org.talend.core.model.repository.IRepositoryViewObject in project tdi-studio-se by Talend.
the class SQLPatternComposite method getAllSqlPatterns.
private List<SQLPatternInfor> getAllSqlPatterns(List<Map> tableInput, boolean modifySQL) {
IElementParameter elementParam = element.getElementParameter(EParameterName.SQLPATTERN_DB_NAME.getName());
if (elementParam == null) {
return Collections.EMPTY_LIST;
}
// String dbName = (String) elementParam.getValue();
List<SQLPatternInfor> patternInfor = new ArrayList<SQLPatternInfor>();
try {
List<IRepositoryViewObject> list = null;
if (isItemIndexChecked() && modifySQL) {
List<Relation> relations = new ArrayList<Relation>();
IProxyRepositoryFactory factory = CorePlugin.getDefault().getProxyRepositoryFactory();
List<IRepositoryViewObject> updateList = new ArrayList<IRepositoryViewObject>();
for (Map map : tableInput) {
String id = (String) map.get(SQLPatternUtils.SQLPATTERNLIST);
relations.addAll(RelationshipItemBuilder.getInstance().getItemsRelatedTo(id, ItemCacheManager.LATEST_VERSION, RelationshipItemBuilder.SQLPATTERN_RELATION));
}
for (Relation relation : relations) {
try {
IRepositoryViewObject obj = factory.getLastVersion(relation.getId());
if (obj != null) {
updateList.add(obj);
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
list = updateList;
} else {
list = DesignerPlugin.getDefault().getRepositoryService().getProxyRepositoryFactory().getAll(ERepositoryObjectType.SQLPATTERNS, false);
// add reference sql pattern
addReferencedSQLTemplate(list, ProjectManager.getInstance().getCurrentProject());
}
for (IRepositoryViewObject repositoryObject : list) {
Item item = repositoryObject.getProperty().getItem();
if (item instanceof SQLPatternItem) {
SQLPatternItem sqlitem = (SQLPatternItem) repositoryObject.getProperty().getItem();
// disable this test as there is now only Generic ELT components
// if (item.getEltName().equals(dbName)) {
patternInfor.add(new SQLPatternInfor(sqlitem.getProperty().getId() + SQLPatternUtils.ID_SEPARATOR + sqlitem.getProperty().getLabel(), sqlitem.getProperty().getLabel()));
// }
}
}
} catch (Exception e) {
ExceptionHandler.process(e);
}
return patternInfor;
}
use of org.talend.core.model.repository.IRepositoryViewObject in project tdi-studio-se by Talend.
the class SQLPatternComposite method addReferencedSQLTemplate.
private void addReferencedSQLTemplate(List<IRepositoryViewObject> list, Project project) {
try {
Context ctx = CorePlugin.getContext();
if (ctx == null) {
return;
}
String parentBranch = ProjectManager.getInstance().getMainProjectBranch(project);
List<ProjectReference> referencedProjects = project.getEmfProject().getReferencedProjects();
for (ProjectReference referenced : referencedProjects) {
if (referenced.getBranch() != null && !parentBranch.equals(referenced.getBranch())) {
continue;
}
org.talend.core.model.properties.Project referencedEmfProject = referenced.getReferencedProject();
EList refeInRef = referencedEmfProject.getReferencedProjects();
Project newProject = new Project(referencedEmfProject);
if (refeInRef != null && refeInRef.size() > 0) {
addReferencedSQLTemplate(list, newProject);
}
List<IRepositoryViewObject> refList;
refList = DesignerPlugin.getDefault().getRepositoryService().getProxyRepositoryFactory().getAll(newProject, ERepositoryObjectType.SQLPATTERNS, false);
for (IRepositoryViewObject repositoryObject : refList) {
Item item = repositoryObject.getProperty().getItem();
if (item instanceof SQLPatternItem) {
if (!((SQLPatternItem) item).isSystem()) {
list.add(repositoryObject);
sqlPatternAndProject.put((SQLPatternItem) item, project);
}
}
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
use of org.talend.core.model.repository.IRepositoryViewObject in project tdi-studio-se by Talend.
the class JSONConnectionContextHelper method convertContextLabel.
/**
*
* change the mode of lebel to Context mode
*
* @param label which you want to convert(it is the name of connection normal)
* @return Context mode label
*/
public static String convertContextLabel(String label) {
if (label != null) {
//$NON-NLS-1$ //$NON-NLS-2$
String newLabel = label.replaceAll("[\\.\\-\\ \\(\\)\\[\\]=]", "_");
//$NON-NLS-1$
Pattern pattern = Pattern.compile("^[0-9]+.*$");
Matcher m = pattern.matcher(newLabel);
if (m.matches()) {
//$NON-NLS-1$
newLabel = "_" + newLabel;
}
//
try {
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
List<IRepositoryViewObject> contextObjectList = factory.getAll(ERepositoryObjectType.CONTEXT, true);
int i = 1;
String tmpLabel = newLabel;
while (!isValidContextName(contextObjectList, tmpLabel)) {
tmpLabel = newLabel + i;
i++;
}
return tmpLabel;
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
return newLabel;
}
return null;
}
Aggregations