use of org.talend.core.model.properties.RoutineItem in project tdi-studio-se by Talend.
the class ImportItemUtil method applyMigrationTasks.
/**
* DOC ycbai Comment method "applyMigrationTasks".
*
* @param itemRecord
* @param monitor
*/
private void applyMigrationTasks(ItemRecord itemRecord, IProgressMonitor monitor) {
Context ctx = CorePlugin.getContext();
RepositoryContext repositoryContext = (RepositoryContext) ctx.getProperty(Context.REPOSITORY_CONTEXT_KEY);
org.talend.core.model.general.Project project = repositoryContext.getProject();
ERepositoryObjectType repositoryType = itemRecord.getRepositoryType();
Item item = null;
try {
List<IRepositoryViewObject> allVersion = ProxyRepositoryFactory.getInstance().getAllVersion(ProjectManager.getInstance().getCurrentProject(), itemRecord.getItemId(), itemRecord.getImportPath(), repositoryType);
for (IRepositoryViewObject repositoryObject : allVersion) {
if (repositoryObject.getProperty().getVersion().equals(itemRecord.getItemVersion())) {
item = repositoryObject.getProperty().getItem();
}
}
if (item == null) {
return;
}
CorePlugin.getDefault().getMigrationToolService().executeMigrationTasksForImport(project, item, itemRecord.getMigrationTasksToApply(), monitor);
if (item instanceof RoutineItem) {
RoutineItem rItem = (RoutineItem) item;
Set<String> set = routineExtModulesMap.get(rItem.getProperty().getId());
if (set == null) {
set = new HashSet<String>();
routineExtModulesMap.put(rItem.getProperty().getId(), set);
}
for (IMPORTType type : (List<IMPORTType>) rItem.getImports()) {
set.add(type.getMODULE());
}
}
itemRecord.setExistingItemWithSameId(null);
itemRecord.clear();
itemRecord.setProperty(item.getProperty());
} catch (Exception e) {
logError(e);
}
}
use of org.talend.core.model.properties.RoutineItem in project tdi-studio-se by Talend.
the class RoutineImportHandler method afterImportingItems.
/*
* (non-Javadoc)
*
* @see org.talend.repository.items.importexport.handlers.imports.ImportRepTypeHandler#afterImportingItemRecords(org
* .eclipse.core.runtime.IProgressMonitor,
* org.talend.repository.items.importexport.ui.wizard.imports.managers.ResourcesManager,
* org.talend.repository.items.importexport.ui.wizard.imports.models.ItemRecord)
*/
@Override
public void afterImportingItems(IProgressMonitor monitor, ResourcesManager resManager, ImportItem selectedItemRecord) {
// deploy routines Jar
final Item item = selectedItemRecord.getItem();
if (validEClass(item) && item instanceof RoutineItem) {
RoutineItem rItem = (RoutineItem) item;
Set<String> extRoutines = new HashSet<String>();
for (IMPORTType type : (List<IMPORTType>) rItem.getImports()) {
extRoutines.add(type.getMODULE());
}
if (resManager instanceof ProviderManager || resManager instanceof ZipFileManager) {
deployJarToDestForArchive(resManager, extRoutines);
} else {
deployJarToDest(resManager, extRoutines);
}
}
super.afterImportingItems(monitor, resManager, selectedItemRecord);
}
use of org.talend.core.model.properties.RoutineItem in project tdi-studio-se by Talend.
the class ConfigExternalJarPage method createControl.
@Override
public void createControl(Composite parent) {
initializeDialogUnits(parent);
Composite composite = new Composite(parent, SWT.NULL);
composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL));
composite.setLayout(new GridLayout(3, false));
composite.setFont(parent.getFont());
libField = new //$NON-NLS-1$
EditJavaRoutineExternalJarField(//$NON-NLS-1$
Messages.getString("ImportExternalJarPage.fileField.label"), composite, isReadOnly());
RoutineItem routine = getSelectedRoutine();
routines = routine.getImports();
libField.setInput(routines);
Button button = new Button(composite, getMessageType());
//$NON-NLS-1$
button.setText(Messages.getString("ConfigExternalJarPage.reloadLibrary"));
button.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
}
@Override
public void widgetSelected(SelectionEvent e) {
for (int i = 0; i < routines.size(); i++) {
String value = ((IMPORTType) routines.get(i)).getUrlPath();
File file = new File(value);
if (file.exists()) {
try {
CorePlugin.getDefault().getLibrariesService().deployLibrary(file.toURL());
} catch (MalformedURLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
}
}
});
// should not initially have error message
setErrorMessage(null);
setControl(composite);
}
use of org.talend.core.model.properties.RoutineItem in project tdi-studio-se by Talend.
the class ConfigExternalPerlModulePage method createControl.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
*/
public void createControl(Composite parent) {
initializeDialogUnits(parent);
Composite composite = new Composite(parent, SWT.NULL);
composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL));
composite.setLayout(new GridLayout(3, false));
composite.setFont(parent.getFont());
libField = new EditPerlRoutineExternalModuleField(Messages.getString("ConfigExternalPerlModulePage.moduleFieldLabel"), //$NON-NLS-1$
composite);
RoutineItem routine = getSelectedRoutine();
EList routines = routine.getImports();
libField.setInput(routines);
// should not initially have error message
setErrorMessage(null);
setControl(composite);
}
use of org.talend.core.model.properties.RoutineItem in project tdi-studio-se by Talend.
the class ChangeModelForRoutineParameterMigrationTask2 method execute.
@SuppressWarnings("unchecked")
@Override
public ExecutionResult execute(Item item) {
try {
List<String> possibleRoutines = new ArrayList<String>();
List<String> routinesToAdd = new ArrayList<String>();
String additionalString = LanguageManager.getCurrentLanguage() == ECodeLanguage.JAVA ? "." : "";
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
List<IRepositoryViewObject> routines = factory.getAll(ProjectManager.getInstance().getCurrentProject(), ERepositoryObjectType.ROUTINES);
// always add the system, others must be checked
for (IRepositoryViewObject object : routines) {
if (((RoutineItem) object.getProperty().getItem()).isBuiltIn()) {
routinesToAdd.add(object.getLabel());
} else {
possibleRoutines.add(object.getLabel());
}
}
for (Project project : ProjectManager.getInstance().getAllReferencedProjects()) {
List<IRepositoryViewObject> refRoutines = factory.getAll(project, ERepositoryObjectType.ROUTINES);
for (IRepositoryViewObject object : refRoutines) {
if (!((RoutineItem) object.getProperty().getItem()).isBuiltIn()) {
if (!possibleRoutines.contains(object.getLabel())) {
possibleRoutines.add(object.getLabel());
routines.add(object);
}
}
}
}
List<RoutinesParameterType> oldList = Collections.EMPTY_LIST;
ProcessType processType = getProcessType(item);
if (null != processType) {
if (processType.getParameters() != null && processType.getParameters().getRoutinesParameter() == null) {
ParametersType parameterType = TalendFileFactory.eINSTANCE.createParametersType();
processType.setParameters(parameterType);
if (item instanceof ProcessItem) {
routinesToAdd.addAll(possibleRoutines);
possibleRoutines.clear();
}
} else {
if (processType.getParameters() == null) {
processType.setParameters(TalendFileFactory.eINSTANCE.createParametersType());
}
oldList = new ArrayList<RoutinesParameterType>(processType.getParameters().getRoutinesParameter());
if (oldList.isEmpty() && item instanceof ProcessItem) {
routinesToAdd.addAll(possibleRoutines);
possibleRoutines.clear();
}
processType.getParameters().getRoutinesParameter().clear();
}
if (processType.getRoutinesDependencies() != null && !processType.getRoutinesDependencies().isEmpty()) {
processType.getRoutinesDependencies().clear();
}
List<RoutinesParameterType> routinesDependencies = (List<RoutinesParameterType>) processType.getParameters().getRoutinesParameter();
if (!possibleRoutines.isEmpty()) {
// check possible routines to setup in process
for (ElementParameterType param : (List<ElementParameterType>) processType.getParameters().getElementParameter()) {
for (String routine : possibleRoutines) {
if (!routinesToAdd.contains(routine) && param.getValue() != null && param.getValue().contains(routine + additionalString)) {
routinesToAdd.add(routine);
}
for (ElementValueType elementValue : (List<ElementValueType>) param.getElementValue()) {
if (!routinesToAdd.contains(routine) && elementValue.getValue() != null && elementValue.getValue().contains(routine + additionalString)) {
routinesToAdd.add(routine);
}
}
}
}
// check possible routines to setup in nodes
for (NodeType node : ((List<NodeType>) processType.getNode())) {
for (ElementParameterType param : (List<ElementParameterType>) node.getElementParameter()) {
for (String routine : possibleRoutines) {
if (!routinesToAdd.contains(routine) && param.getValue() != null && param.getValue().contains(routine + additionalString)) {
routinesToAdd.add(routine);
}
for (ElementValueType elementValue : (List<ElementValueType>) param.getElementValue()) {
if (!routinesToAdd.contains(routine) && elementValue.getValue() != null && elementValue.getValue().contains(routine + additionalString)) {
routinesToAdd.add(routine);
}
}
}
}
}
// check possible routines to setup in connections
for (ConnectionType connection : ((List<ConnectionType>) processType.getConnection())) {
for (ElementParameterType param : (List<ElementParameterType>) connection.getElementParameter()) {
for (String routine : possibleRoutines) {
if (!routinesToAdd.contains(routine) && param.getValue() != null && param.getValue().contains(routine + additionalString)) {
routinesToAdd.add(routine);
}
for (ElementValueType elementValue : (List<ElementValueType>) param.getElementValue()) {
if (!routinesToAdd.contains(routine) && elementValue.getValue() != null && elementValue.getValue().contains(routine + additionalString)) {
routinesToAdd.add(routine);
}
}
}
}
}
}
// just in case some routine dependencies exist before but are lost... (migration from 4.1.1 or 4.1.2)
for (RoutinesParameterType routine : oldList) {
if (!routinesToAdd.contains(routine.getName())) {
routinesDependencies.add(routine);
}
}
for (IRepositoryViewObject object : routines) {
if (routinesToAdd.contains(object.getLabel())) {
RoutinesParameterType routinesParameterType = TalendFileFactory.eINSTANCE.createRoutinesParameterType();
routinesParameterType.setId(object.getId());
routinesParameterType.setName(object.getLabel());
routinesDependencies.add(routinesParameterType);
}
}
factory.save(item, true);
}
return ExecutionResult.SUCCESS_NO_ALERT;
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
Aggregations