use of org.talend.core.model.repository.IRepositoryViewObject in project tdi-studio-se by Talend.
the class DowngradeParameterHelper method getOldLabelFromId.
/**
* DOC nrousseau Comment method "getOldLabelFromId".
*
* @param id
* @param type
* @return
*/
private static String getOldLabelFromId(String id, ERepositoryObjectType type) {
final IProxyRepositoryFactory proxyRepositoryFactory = DesignerPlugin.getDefault().getProxyRepositoryFactory();
try {
ERepositoryObjectType repositoryConnectionsNeeded;
if (type == ERepositoryObjectType.METADATA_CON_QUERY) {
repositoryConnectionsNeeded = ERepositoryObjectType.METADATA_CONNECTIONS;
} else {
repositoryConnectionsNeeded = ERepositoryObjectType.METADATA;
}
List<IRepositoryViewObject> objects = proxyRepositoryFactory.getAll(repositoryConnectionsNeeded);
ConnectionItem connectionItem = null;
for (IRepositoryViewObject object : objects) {
connectionItem = (ConnectionItem) object.getProperty().getItem();
if (type == ERepositoryObjectType.METADATA_CON_QUERY) {
QueriesConnection queries = connectionItem.getConnection().getQueries();
if (queries == null) {
continue;
}
for (Query query : (List<Query>) queries.getQuery()) {
if (query.getId().equals(id)) {
return connectionItem.getProperty().getId() + SEPARATOR + query.getLabel();
}
}
} else if (type == ERepositoryObjectType.METADATA_CON_TABLE) {
for (MetadataTable table : (Set<MetadataTable>) ConnectionHelper.getTables(connectionItem.getConnection())) {
if (table.getId().equals(id)) {
return connectionItem.getProperty().getId() + SEPARATOR + table.getLabel();
}
}
}
}
} catch (PersistenceException e) {
return null;
}
return null;
}
use of org.talend.core.model.repository.IRepositoryViewObject in project tdi-studio-se by Talend.
the class JavaProcessorUtilities method getNeededModulesForProcess.
public static Set<ModuleNeeded> getNeededModulesForProcess(IProcess process) {
Set<ModuleNeeded> neededLibraries = new TreeSet<ModuleNeeded>(new Comparator<ModuleNeeded>() {
@Override
public int compare(ModuleNeeded m1, ModuleNeeded m2) {
return m1.toString().compareTo(m2.toString());
}
});
Set<ModuleNeeded> neededModules = LastGenerationInfo.getInstance().getModulesNeededWithSubjobPerJob(process.getId(), process.getVersion());
neededLibraries.addAll(neededModules);
if (process == null || !(process instanceof IProcess2)) {
if (neededLibraries.isEmpty() && process != null) {
neededLibraries = process.getNeededModules(true);
if (neededLibraries == null) {
neededLibraries = new HashSet<ModuleNeeded>();
// for (ModuleNeeded moduleNeeded : ModulesNeededProvider.getModulesNeeded()) {
// neededLibraries.add(moduleNeeded.getModuleName());
// }
}
} else {
for (ModuleNeeded moduleNeeded : ModulesNeededProvider.getRunningModules()) {
neededLibraries.add(moduleNeeded);
}
}
return neededLibraries;
}
Property property = ((IProcess2) process).getProperty();
if (neededLibraries.isEmpty()) {
neededLibraries = process.getNeededModules(true);
if (neededLibraries == null) {
neededLibraries = new HashSet<ModuleNeeded>();
for (ModuleNeeded moduleNeeded : ModulesNeededProvider.getModulesNeeded()) {
neededLibraries.add(moduleNeeded);
}
}
} else {
if (property != null && property.getItem() instanceof ProcessItem) {
neededLibraries.addAll(ModulesNeededProvider.getModulesNeededForProcess((ProcessItem) property.getItem(), process));
} else {
for (ModuleNeeded moduleNeeded : ModulesNeededProvider.getRunningModules()) {
neededLibraries.add(moduleNeeded);
}
}
}
if (property != null && GlobalServiceRegister.getDefault().isServiceRegistered(ICamelDesignerCoreService.class)) {
ICamelDesignerCoreService camelService = (ICamelDesignerCoreService) GlobalServiceRegister.getDefault().getService(ICamelDesignerCoreService.class);
if (camelService.isInstanceofCamel(property.getItem())) {
// http://jira.talendforge.org/browse/TESB-5887 LiXiaopeng 2012-6-19
// Synchronize Route resources
camelService.synchronizeRouteResource((ProcessItem) property.getItem());
try {
for (IRepositoryViewObject object : CoreRuntimePlugin.getInstance().getProxyRepositoryFactory().getAll(camelService.getBeansType())) {
Item item = object.getProperty().getItem();
if (item instanceof RoutineItem) {
RoutineItem routine = (RoutineItem) item;
for (Object o : routine.getImports()) {
IMPORTType type = (IMPORTType) o;
ModuleNeeded neededModule = new ModuleNeeded("camel bean dependencies", type.getMODULE(), "camel bean dependencies", true);
neededLibraries.add(neededModule);
}
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
}
return neededLibraries;
}
use of org.talend.core.model.repository.IRepositoryViewObject in project tdi-studio-se by Talend.
the class VersionManagementPage method versionLatest.
private void versionLatest() {
List<ItemVersionObject> tableList = new ArrayList<ItemVersionObject>();
tableList.addAll(checkedObjects);
for (ItemVersionObject object : checkedObjects) {
if (object.getRepositoryNode() != null) {
List<Relation> relations = builder.getItemsJobRelatedTo(object.getRepositoryNode().getId(), object.getOldVersion(), RelationshipItemBuilder.JOB_RELATION);
for (Relation relation : relations) {
try {
IRepositoryViewObject obj = FACTORY.getLastVersion(relation.getId());
if (obj != null) {
for (ItemVersionObject obj2 : versionObjects) {
if (obj2.getItem() == obj.getProperty().getItem()) {
ItemVersionObject relat = obj2;
if (!tableList.contains(relat)) {
tableList.add(relat);
checkAllVerSionLatest(tableList, relat);
}
break;
}
}
}
} catch (PersistenceException et) {
ExceptionHandler.process(et);
}
}
}
}
removeItemElements(checkedObjects);
checkedObjects.clear();
checkedObjects.addAll(tableList);
refreshTableItems();
refreshCheckedTreeView();
}
use of org.talend.core.model.repository.IRepositoryViewObject in project tdi-studio-se by Talend.
the class VersionManagementPage method updateItemsVersion.
@Override
protected void updateItemsVersion() {
final IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
@Override
public void run(final IProgressMonitor monitor) throws CoreException {
RepositoryWorkUnit<Object> rwu = new RepositoryWorkUnit<Object>(project, "Update items version") {
@Override
protected void run() throws LoginException, PersistenceException {
//$NON-NLS-1$
monitor.beginTask("Update items version", checkedObjects.size());
Map<String, String> versions = new HashMap<String, String>();
for (int i = 0; i < checkedObjects.size(); i++) {
ItemVersionObject object = checkedObjects.get(i);
versions.put(object.getItem().getProperty().getId(), object.getOldVersion());
}
for (ItemVersionObject object : checkedObjects) {
IRepositoryViewObject repositoryObject = object.getRepositoryNode().getObject();
if (repositoryObject != null && repositoryObject.getProperty() != null) {
if (!object.getNewVersion().equals(repositoryObject.getVersion())) {
final Item item = object.getItem();
Property itemProperty = item.getProperty();
itemProperty.setVersion(object.getNewVersion());
monitor.subTask(itemProperty.getLabel());
try {
// for bug 12853 ,version management doesn't work for joblet because eResource
// is null
IRepositoryViewObject obj = null;
if (itemProperty.eResource() == null) {
ItemState state = item.getState();
if (state != null && state.getPath() != null) {
obj = FACTORY.getLastVersion(project, itemProperty.getId(), state.getPath(), object.getRepositoryNode().getObjectType());
} else {
obj = FACTORY.getLastVersion(project, itemProperty.getId());
}
}
if (obj != null) {
// obj.setVersion(object.getNewVersion());
FACTORY.save(project, obj.getProperty());
builder.addOrUpdateItem(obj.getProperty().getItem(), true);
} else {
String id = itemProperty.getId();
FACTORY.save(project, itemProperty);
if (versionLatest.getSelection()) {
builder.updateItemVersion(item, object.getOldVersion(), id, versions, true);
}
builder.addOrUpdateItem(item, true);
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
}
monitor.worked(1);
}
try {
FACTORY.saveProject(project);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
};
rwu.setAvoidUnloadResources(true);
rwu.executeRun();
monitor.done();
}
};
IRunnableWithProgress iRunnableWithProgress = new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
try {
ISchedulingRule schedulingRule = workspace.getRoot();
// the update the project files need to be done in the workspace runnable to avoid all notification
// of changes before the end of the modifications.
workspace.run(runnable, schedulingRule, IWorkspace.AVOID_UPDATE, monitor);
} catch (CoreException e) {
ExceptionHandler.process(e);
}
}
};
// final ProgressMonitorJobsDialog dialog = new ProgressMonitorJobsDialog(null);
final ProgressMonitorDialog dialog = new ProgressMonitorDialog(null);
try {
dialog.run(false, false, iRunnableWithProgress);
} catch (InvocationTargetException e) {
ExceptionHandler.process(e);
} catch (InterruptedException e) {
ExceptionHandler.process(e);
}
}
use of org.talend.core.model.repository.IRepositoryViewObject in project tdi-studio-se by Talend.
the class VersionManagementPage method selectAllDependencies.
private void selectAllDependencies() {
List<ItemVersionObject> tableList = new ArrayList<ItemVersionObject>();
tableList.addAll(checkedObjects);
IProxyRepositoryFactory factory = CorePlugin.getDefault().getProxyRepositoryFactory();
for (ItemVersionObject object : checkedObjects) {
if (object.getRepositoryNode() != null) {
List<Relation> relations = builder.getItemsRelatedTo(object.getRepositoryNode().getId(), object.getOldVersion(), RelationshipItemBuilder.JOB_RELATION);
for (Relation relation : relations) {
IRepositoryViewObject obj = null;
try {
if (RelationshipItemBuilder.ROUTINE_RELATION.equals(relation.getType())) {
obj = RoutinesUtil.getRoutineFromName(relation.getId());
} else {
obj = factory.getLastVersion(relation.getId());
}
if (obj != null) {
for (ItemVersionObject obj2 : versionObjects) {
if (obj2.getItem() == obj.getProperty().getItem()) {
ItemVersionObject relat = obj2;
if (!tableList.contains(relat)) {
tableList.add(relat);
checkAllVerSionLatest(tableList, relat);
}
break;
}
}
}
} catch (PersistenceException et) {
ExceptionHandler.process(et);
}
}
}
}
removeItemElements(checkedObjects);
checkedObjects.clear();
checkedObjects.addAll(tableList);
refreshTableItems();
refreshCheckedTreeView();
}
Aggregations