use of org.talend.commons.exception.PersistenceException in project tdi-studio-se by Talend.
the class OpenExistVersionProcessWizard method refreshNewJob.
protected boolean refreshNewJob() {
if (alreadyEditedByUser) {
return false;
}
boolean lastVersion = true;
StructuredSelection selection = (StructuredSelection) mainPage.getSelection();
if (selection != null && !selection.isEmpty()) {
RepositoryNode node = (RepositoryNode) selection.getFirstElement();
lastVersion = node.getObject().getVersion().equals(originalVersion);
if (!lastVersion) {
originalVersion = node.getObject().getVersion();
String newVersion = mainPage.getNewVersion();
processObject = node.getObject();
processObject.getProperty().setVersion(newVersion);
}
}
if (lastVersion) {
getProperty().setVersion(mainPage.getNewVersion());
}
IProxyRepositoryFactory repositoryFactory = CorePlugin.getDefault().getRepositoryService().getProxyRepositoryFactory();
try {
repositoryFactory.save(getProperty(), this.originaleObjectLabel, this.originalVersion);
ExpressionPersistance.getInstance().jobNameChanged(originaleObjectLabel, processObject.getLabel());
ProxyRepositoryFactory.getInstance().saveProject(ProjectManager.getInstance().getCurrentProject());
return true;
} catch (PersistenceException e) {
MessageBoxExceptionHandler.process(e);
return false;
}
}
use of org.talend.commons.exception.PersistenceException 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.commons.exception.PersistenceException 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.commons.exception.PersistenceException in project tdi-studio-se by Talend.
the class JSONWizard method performFinish.
/**
* This method determine if the 'Finish' button is enable This method is called when 'Finish' button is pressed in
* the wizard. We will create an operation and run it using wizard as execution context.
*/
@Override
public boolean performFinish() {
boolean formIsPerformed = false;
IWizardPage finalPage = getCurrentPage();
if (finalPage == null) {
finalPage = propertiesWizardPage;
}
// deleteTemFile();
if (connection.isInputModel()) {
if (finalPage instanceof JSONFileWizardPage) {
int step = ((JSONFileWizardPage) finalPage).step;
if (step == 2) {
formIsPerformed = finalPage.isPageComplete();
if (formIsPerformed) {
List schemas = connection.getSchema();
Set tables = ConnectionHelper.getTables(connection);
if (!schemas.isEmpty() && !tables.isEmpty()) {
JSONXPathLoopDescriptor currentSchema = (JSONXPathLoopDescriptor) schemas.get(0);
MetadataTable currentTable = (MetadataTable) tables.toArray(new MetadataTable[0])[0];
if (!currentSchema.getAbsoluteXPathQuery().equals(oldAbstractQueryPath)) {
resetMetadata(currentSchema.getSchemaTargets(), true);
} else {
resetMetadata(currentSchema.getSchemaTargets(), false);
}
}
}
} else {
formIsPerformed = finalPage.isPageComplete();
}
} else {
formIsPerformed = finalPage.isPageComplete();
}
} else {
formIsPerformed = finalPage.isPageComplete();
}
if (formIsPerformed) {
final IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
final IWorkspaceRunnable op = new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
@Override
public void run() {
if (creation) {
String nextId = factory.getNextId();
connectionProperty.setId(nextId);
// changed by hqzhang for TDI-19527, label=displayName
connectionProperty.setLabel(connectionProperty.getDisplayName());
final RepositoryWorkUnit<Object> workUnit = new RepositoryWorkUnit<Object>("", this) {
@Override
protected void run() throws LoginException, PersistenceException {
factory.create(connectionItem, propertiesWizardPage.getDestinationPath());
}
};
workUnit.setAvoidUnloadResources(true);
factory.executeRepositoryWorkUnit(workUnit);
} else {
// changed by hqzhang for TDI-19527, label=displayName
connectionProperty.setLabel(connectionProperty.getDisplayName());
// update schemas
Map<String, SchemaTarget> schemaTargetMap = new HashMap<String, SchemaTarget>();
EList<JSONXPathLoopDescriptor> schema = connection.getSchema();
if (schema != null && schema.size() > 0) {
JSONXPathLoopDescriptor jsonXPathLoopDescriptor = schema.get(0);
if (jsonXPathLoopDescriptor != null) {
EList<SchemaTarget> schemaTargets = jsonXPathLoopDescriptor.getSchemaTargets();
if (schemaTargets != null && schemaTargets.size() > 0) {
for (SchemaTarget schemaTarget : schemaTargets) {
schemaTargetMap.put(schemaTarget.getTagName(), schemaTarget);
}
}
}
}
Map<String, MetadataColumn> columnsMap = new HashMap<String, MetadataColumn>();
MetadataTable[] tables = ConnectionHelper.getTables(connectionItem.getConnection()).toArray(new MetadataTable[0]);
for (MetadataTable table : tables) {
EList<MetadataColumn> columns = table.getColumns();
Iterator<MetadataColumn> columnsIter = columns.iterator();
while (columnsIter.hasNext()) {
MetadataColumn column = columnsIter.next();
if (connection.isInputModel()) {
if (schemaTargetMap.get(column.getLabel()) == null) {
columnsIter.remove();
} else {
columnsMap.put(column.getLabel(), column);
}
} else {
columnsMap.put(column.getLabel(), column);
}
}
}
boolean hasAddedColumns = false;
Iterator<Entry<String, SchemaTarget>> schemaTargetIter = schemaTargetMap.entrySet().iterator();
while (schemaTargetIter.hasNext()) {
Map.Entry<String, SchemaTarget> entry = schemaTargetIter.next();
String key = entry.getKey();
if (columnsMap.get(key) == null) {
hasAddedColumns = true;
break;
}
}
if (hasAddedColumns) {
MessageDialog.openInformation(getShell(), "Detect new columns", "There are some new fields to extract, guess your schema manually if you want to apply the update.");
}
// update
RepositoryUpdateManager.updateFileConnection(connectionItem);
refreshInFinish(propertiesWizardPage.isNameModifiedByUser());
final RepositoryWorkUnit<Object> workUnit = new RepositoryWorkUnit<Object>("", this) {
@Override
protected void run() throws LoginException, PersistenceException {
factory.save(connectionItem);
}
};
workUnit.setAvoidUnloadResources(true);
factory.executeRepositoryWorkUnit(workUnit);
closeLockStrategy();
}
final RepositoryWorkUnit<Object> workUnit = new RepositoryWorkUnit<Object>("", this) {
@Override
protected void run() throws LoginException, PersistenceException {
ProxyRepositoryFactory.getInstance().saveProject(ProjectManager.getInstance().getCurrentProject());
}
};
workUnit.setAvoidUnloadResources(true);
factory.executeRepositoryWorkUnit(workUnit);
}
});
}
};
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(op, schedulingRule, IWorkspace.AVOID_UPDATE, monitor);
} catch (CoreException e) {
throw new InvocationTargetException(e);
}
}
};
try {
new ProgressMonitorDialog(null).run(true, true, iRunnableWithProgress);
} catch (InvocationTargetException e) {
ExceptionHandler.process(e);
} catch (InterruptedException e) {
//
}
return true;
} else {
return false;
}
}
use of org.talend.commons.exception.PersistenceException in project tdi-studio-se by Talend.
the class ChangeValue4BonitaComponents method execute.
@Override
public ExecutionResult execute(Item item) {
final ProcessType processType = getProcessType(item);
String[] compNames = { "tBonitaDeploy", "tBonitaInstantiateProcess" };
IComponentConversion conversion = new IComponentConversion() {
public void transform(NodeType node) {
if (node == null) {
return;
}
ElementParameterType parameter = ComponentUtilities.getNodeProperty(node, "DB_VERSION");
if (parameter != null) {
String value = parameter.getValue();
if (value == null) {
return;
}
String oldValue523Prefix = "bonita-client-5.2.3.jar";
String oldValue531Prefix = "bonita-client-5.3.jar";
if (value.startsWith(oldValue523Prefix)) {
String newValue = "antlr-2.7.6.jar;asm-1.5.3.jar;asm-3.1.jar;asm-attrs-1.5.3.jar;cglib-nodep-2.1_3.jar;commons-collections-2.1.1.jar;commons-logging-1.0.4.jar;dom4j-1.6.1.jar;ehcache-1.2.3.jar;groovy-all-1.7.0.jar;h2-1.2.132.jar;hibernate-3.2.6.ga.jar;jline-0.9.94.jar;jta-1.1.jar;novaBpmIdentity-1.0.jar;novaBpmPerf-1.0.jar;novaBpmUtil-1.0.jar";
ComponentUtilities.setNodeValue(node, "DB_VERSION", newValue);
} else if (value.startsWith(oldValue531Prefix)) {
String newValue = "novaBpmIdentity-1.0.jar;novaBpmPerf-1.0.jar;novaBpmUtil-1.0.jar;hibernate-core-3.5.6-Final.jar;commons-collections-3.1.jar;ehcache-core-2.2.0.jar;hibernate-commons-annotations-3.2.0.Final.jar;hibernate-search-3.2.1.Final.jar;javassist-3.8.0.GA.jar;lucene-core-2.9.3.jar;slf4j-api-1.6.1.jar;dom4j-1.6.1.jar;h2-1.2.132.jar;jta-1.1.jar;antlr-2.7.6.jar;commons-logging-1.1.1.jar";
ComponentUtilities.setNodeValue(node, "DB_VERSION", newValue);
}
}
}
};
for (String name : compNames) {
IComponentFilter filter = new NameComponentFilter(name);
try {
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(conversion));
} catch (PersistenceException e) {
// TODO Auto-generated catch block
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
return ExecutionResult.SUCCESS_NO_ALERT;
}
Aggregations