use of org.talend.designer.core.model.utils.emf.talendfile.RoutinesParameterType in project tdi-studio-se by Talend.
the class WSDL2JAVAController method generateJavaFile.
/*
* (non-Javadoc)
*
* @see
* org.talend.designer.core.ui.editor.properties2.editors.AbstractElementPropertySectionController#createCommand()
*/
private void generateJavaFile() {
final IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
RepositoryWorkUnit<Object> workUnit = new //$NON-NLS-1$
RepositoryWorkUnit<Object>(//$NON-NLS-1$
"", //$NON-NLS-1$
this) {
@Override
protected void run() throws PersistenceException {
Node node = (Node) elem;
IProcess process = node.getProcess();
String jobName = process.getName();
String nodeName = node.getUniqueName();
//$NON-NLS-1$
String wsdlfile = (String) node.getPropertyValue("ENDPOINT");
wsdlfile = wsdlfile.substring(1, wsdlfile.length() - 1);
if (wsdlfile.equals("")) {
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
MessageDialog.openError(Display.getDefault().getActiveShell(), org.talend.designer.core.i18n.Messages.getString("WSDL2JAVAController.TOS"), org.talend.designer.core.i18n.Messages.getString("WSDL2JAVAController.WSDLEquals"));
}
});
return;
}
File dir = new File(getTmpFolder());
final TalendWSDL2Java java2WSDL = new TalendWSDL2Java();
//$NON-NLS-1$ //$NON-NLS-2$
boolean hasError = java2WSDL.generateWSDL(new String[] { "-o" + dir, "-p" + PACK, wsdlfile });
// give some info about the generate stub.jar result to GUI.
final String tempWsdlfile = wsdlfile;
if (hasError) {
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
MessageDialog.openError(Display.getDefault().getActiveShell(), org.talend.designer.core.i18n.Messages.getString("WSDL2JAVAController.TOS"), //$NON-NLS-1$ //$NON-NLS-2$
org.talend.designer.core.i18n.Messages.getString(//$NON-NLS-1$ //$NON-NLS-2$
"WSDL2JAVAController.generateFileFailed", java2WSDL.getException().getClass().getCanonicalName(), java2WSDL.getException().getMessage()));
}
});
} else {
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
MessageDialog.openInformation(Display.getDefault().getActiveShell(), //$NON-NLS-1$
org.talend.designer.core.i18n.Messages.getString("WSDL2JAVAController.TOS"), org.talend.designer.core.i18n.Messages.getString("WSDL2JAVAController.generateFileFailedFromWSDL", //$NON-NLS-1$
tempWsdlfile));
}
});
}
//$NON-NLS-1$
IPath path = new Path(jobName + "/" + nodeName);
//$NON-NLS-1$
String[] filter = new String[] { "java" };
Collection listFiles = FileUtils.listFiles(dir, filter, true);
Iterator iterator = listFiles.iterator();
String name = "";
for (int i = 0; i < listFiles.size(); i++) {
File javaFile = (File) listFiles.toArray()[i];
String parentFileName = javaFile.getParentFile().getName();
if (!parentFileName.equals("routines")) {
name = parentFileName;
}
}
List<RoutineItem> returnItemList = new ArrayList<RoutineItem>();
while (iterator.hasNext()) {
File javaFile = (File) iterator.next();
String fileName = javaFile.getName();
String label = fileName.substring(0, fileName.indexOf('.'));
try {
RoutineItem returnItem = createRoutine(path, label, javaFile, name);
returnItemList.add(returnItem);
syncRoutine(returnItem, true, name);
refreshProject();
} catch (IllegalArgumentException e) {
// nothing need to do for the duplicate label, there don't overwrite it.
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
Project currentProject = ProjectManager.getInstance().getCurrentProject();
IRepositoryService service = (IRepositoryService) GlobalServiceRegister.getDefault().getService(IRepositoryService.class);
IProxyRepositoryFactory factory = service.getProxyRepositoryFactory();
List<IRepositoryViewObject> all;
Item item = null;
try {
all = factory.getAll(currentProject, ERepositoryObjectType.PROCESS, true, true);
for (IRepositoryViewObject repositoryViewObject : all) {
if (repositoryViewObject.getLabel().equals(jobName)) {
item = repositoryViewObject.getProperty().getItem();
}
}
} catch (PersistenceException ex) {
ExceptionHandler.process(ex);
}
try {
List<RoutinesParameterType> needList = new ArrayList<RoutinesParameterType>();
List<RoutinesParameterType> createJobRoutineDependencies = RoutinesUtil.createJobRoutineDependencies(false);
for (RoutineItem returnItem : returnItemList) {
for (RoutinesParameterType routinesParameterType : createJobRoutineDependencies) {
if (routinesParameterType.getId().equals(returnItem.getProperty().getId())) {
needList.add(routinesParameterType);
}
}
}
if (process instanceof org.talend.designer.core.ui.editor.process.Process) {
((org.talend.designer.core.ui.editor.process.Process) process).addGeneratingRoutines(needList);
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
// try {
// RoutinesUtil.createJobRoutineDependencies(false);
// } catch (PersistenceException e) {
// ExceptionHandler.process(e);
// }
FilesUtils.removeFolder(dir, true);
}
};
workUnit.setAvoidUnloadResources(true);
factory.executeRepositoryWorkUnit(workUnit);
}
use of org.talend.designer.core.model.utils.emf.talendfile.RoutinesParameterType in project tdi-studio-se by Talend.
the class AbstractStandardJobBuildProviderTest method createJobItem.
protected Item createJobItem() throws PersistenceException {
final IProxyRepositoryFactory repositoryFactory = DesignerPlugin.getDefault().getRepositoryService().getProxyRepositoryFactory();
final String testJobId = repositoryFactory.getNextId();
final String testJobLabel = StandardJobStandaloneBuildProvider.class.getSimpleName() + System.currentTimeMillis();
// copied from NewProcessWizard
Property property = PropertiesFactory.eINSTANCE.createProperty();
property.setAuthor(((RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getUser());
property.setVersion(VersionUtils.DEFAULT_VERSION);
property.setStatusCode("");
property.setId(testJobId);
property.setDisplayName(testJobLabel);
property.setLabel(property.getDisplayName());
ProcessItem processItem = PropertiesFactory.eINSTANCE.createProcessItem();
processItem.setProperty(property);
property.setItem(processItem);
ProcessType process = TalendFileFactory.eINSTANCE.createProcessType();
ParametersType parameterType = TalendFileFactory.eINSTANCE.createParametersType();
List<RoutinesParameterType> dependenciesInPreference = RoutinesUtil.createDependenciesInPreference();
parameterType.getRoutinesParameter().addAll(dependenciesInPreference);
process.setParameters(parameterType);
processItem.setProcess(process);
repositoryFactory.create(processItem, new Path(""));
return processItem;
}
use of org.talend.designer.core.model.utils.emf.talendfile.RoutinesParameterType in project tdi-studio-se by Talend.
the class JobVersionUtilsTest method createRepositoryObject.
private IRepositoryViewObject createRepositoryObject(String lable) throws PersistenceException {
// create item
itemPath = new Path(folderName);
Property property = PropertiesFactory.eINSTANCE.createProperty();
property.setAuthor(((RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getUser());
property.setVersion(VersionUtils.DEFAULT_VERSION);
//$NON-NLS-1$
property.setStatusCode("");
ProcessItem processItem = PropertiesFactory.eINSTANCE.createProcessItem();
processItem.setProperty(property);
repositoryFactory = RepositoryPlugin.getDefault().getRepositoryService().getProxyRepositoryFactory();
property.setId(repositoryFactory.getNextId());
property.setLabel(lable);
ProcessType process = TalendFileFactory.eINSTANCE.createProcessType();
ParametersType parameterType = TalendFileFactory.eINSTANCE.createParametersType();
// add depended routines.
List<RoutinesParameterType> dependenciesInPreference = RoutinesUtil.createDependenciesInPreference();
parameterType.getRoutinesParameter().addAll(dependenciesInPreference);
process.setParameters(parameterType);
processItem.setProcess(process);
repositoryFactory.create(processItem, itemPath);
return new RepositoryObject(property);
}
use of org.talend.designer.core.model.utils.emf.talendfile.RoutinesParameterType in project tdi-studio-se by Talend.
the class SetupProcessDependenciesRoutinesDialog method init.
@SuppressWarnings("unchecked")
private void init(ProcessType process) {
allRoutineItems.clear();
ProjectManager projectManager = ProjectManager.getInstance();
Project currentProject = projectManager.getCurrentProject();
initModels(currentProject);
Set<Project> referenceProjects = new HashSet<Project>();
this.getAllReferenceProjects(currentProject, referenceProjects);
initRefProjects(referenceProjects);
List<RoutinesParameterType> routinesDependencies = process.getParameters().getRoutinesParameter();
List<String> typeNames = new ArrayList<String>();
for (RoutinesParameterType type : routinesDependencies) {
RoutineItemRecord record = new RoutineItemRecord();
record.setName(type.getName());
Property property = findObject(type.getId(), type.getName());
if (property != null) {
// if system, id is not used
record.setId(property.getId());
record.setLabel(property.getLabel());
} else {
record.setHasProblem(true);
// use the record
record.setLabel(type.getName());
}
if (!record.hasProblem()) {
// if lost, willn't display
if (((RoutineItem) property.getItem()).isBuiltIn()) {
systemRoutines.add(record);
} else {
if (typeNames.contains(type.getName())) {
break;
} else {
typeNames.add(type.getName());
userRoutines.add(record);
}
}
}
}
}
use of org.talend.designer.core.model.utils.emf.talendfile.RoutinesParameterType in project tdi-studio-se by Talend.
the class ChangeModelForRoutineParameterMigrationTask method execute.
@SuppressWarnings("unchecked")
@Override
public ExecutionResult execute(Item item) {
if (!(item instanceof ProcessItem)) {
return ExecutionResult.NOTHING_TO_DO;
}
try {
ProcessItem item2 = (ProcessItem) item;
List<ItemInforType> oldRoutinesDependencies = (List<ItemInforType>) item2.getProcess().getRoutinesDependencies();
if (item2.getProcess().getParameters() == null || item2.getProcess().getParameters().getRoutinesParameter() == null) {
ParametersType parameterType = TalendFileFactory.eINSTANCE.createParametersType();
item2.getProcess().setParameters(parameterType);
}
List<RoutinesParameterType> routinesDependencies = (List<RoutinesParameterType>) item2.getProcess().getParameters().getRoutinesParameter();
List<IRepositoryViewObject> viewObjects = RoutinesUtil.getCurrentSystemRoutines();
boolean modified = false;
for (ItemInforType added : oldRoutinesDependencies) {
if (added.isSystem()) {
for (int i = 0; i < viewObjects.size(); i++) {
IRepositoryViewObject viewObject = viewObjects.get(i);
if (viewObject.getLabel().equals(added.getIdOrName())) {
RoutinesParameterType routinesParameterType = TalendFileFactory.eINSTANCE.createRoutinesParameterType();
routinesParameterType.setId(viewObject.getId());
routinesParameterType.setName(added.getIdOrName());
routinesDependencies.add(routinesParameterType);
modified = true;
}
}
} else {
IRepositoryViewObject userRoutines = RoutinesUtil.getUserRoutines(added.getIdOrName());
if (userRoutines != null) {
RoutinesParameterType routinesParameterType = TalendFileFactory.eINSTANCE.createRoutinesParameterType();
routinesParameterType.setId(added.getIdOrName());
routinesParameterType.setName(userRoutines.getLabel());
routinesDependencies.add(routinesParameterType);
modified = true;
}
}
}
if (modified) {
oldRoutinesDependencies.clear();
CorePlugin.getDefault().getRepositoryService().getProxyRepositoryFactory().save(item, true);
RelationshipItemBuilder.getInstance().addOrUpdateItem(item, true);
return ExecutionResult.SUCCESS_WITH_ALERT;
}
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
return ExecutionResult.NOTHING_TO_DO;
}
Aggregations