use of org.talend.core.model.repository.IRepositoryViewObject in project tesb-studio-se by Talend.
the class ESBService method changeOtherJobSchemaValue.
// private void changenewOperationLabel(RepositoryNode newNode, INode node, ServiceConnection serConn) {
// String operationName = newNode.getObject().getLabel();
// String parentPortName = newNode.getParent().getObject().getLabel();
//
// String wsdlPath = serConn.getWSDLPath();
// try {
// Map<String, String> serviceParameters = WSDLUtils.getServiceParameters(wsdlPath);
// IRepositoryViewObject newObj = newNode.getObject();
// if (newObj instanceof OperationRepositoryObject) {
// ServiceOperation newOpe = (ServiceOperation) ((OperationRepositoryObject) newObj).getAbstractMetadataObject();
//
// IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
//
// if (newOpe.getReferenceJobId() != null) {
// changeOtherJobSchemaValue(factory, newOpe, serConn);
// MessageDialog.openWarning(new Shell(), "warning",
// "This other job which based on the Operation will be unset!");
// }
//
// IEditorPart activeEditor =
// PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
// IEditorInput input = activeEditor.getEditorInput();
// if (input instanceof ProcessEditorInput) {
// Item jobItem = ((ProcessEditorInput) input).getItem();
// String jobID = jobItem.getProperty().getId();
// String jobName = jobItem.getProperty().getLabel();
//
// newOpe.setReferenceJobId(jobID);
// newOpe.setLabel(newOpe.getName() + "-" + jobName);
//
// serviceParameters.put(WSDLUtils.PORT_NAME, parentPortName);
// serviceParameters.put(WSDLUtils.OPERATION_NAME, operationName);
//
// CreateNewJobAction.setProviderRequestComponentConfiguration(node, serviceParameters);
//
// try {
// factory.save(jobItem);
// } catch (PersistenceException e) {
// e.printStackTrace();
// }
// try {
// factory.save(newNode.getParent().getParent().getObject().getProperty().getItem());
// } catch (PersistenceException e) {
// e.printStackTrace();
// }
// RepositoryManager.refreshSavedNode(newNode);
// }
// }
//
// } catch (CoreException e1) {
// ExceptionHandler.process(e1);
// } catch (PersistenceException e) {
// ExceptionHandler.process(e);
// }
// }
private void changeOtherJobSchemaValue(IProxyRepositoryFactory factory, ServiceOperation newOpe, /*
* ServiceConnection
* serConn,
*/
RepositoryNode selectNode) throws PersistenceException, CoreException {
IRepositoryViewObject jobObj = factory.getLastVersion(newOpe.getReferenceJobId());
if (jobObj == null) {
return;
}
ProcessItem processItem = (ProcessItem) jobObj.getProperty().getItem();
IDesignerCoreService service = CorePlugin.getDefault().getDesignerCoreService();
boolean foundInOpen = false;
IProcess2 process = null;
IEditorReference[] reference = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
List<IProcess2> processes = RepositoryPlugin.getDefault().getDesignerCoreService().getOpenedProcess(reference);
for (IProcess2 processOpen : processes) {
if (processOpen.getProperty().getItem() == processItem) {
foundInOpen = true;
process = processOpen;
break;
}
}
if (!foundInOpen) {
IProcess proc = service.getProcessFromProcessItem(processItem);
if (proc instanceof IProcess2) {
process = (IProcess2) proc;
}
}
newOpe.setReferenceJobId(null);
newOpe.setLabel(newOpe.getName());
if (process != null) {
List<? extends INode> nodelist = process.getGraphicalNodes();
for (INode node : nodelist) {
if (node.getComponent().getName().equals("tESBProviderRequest")) {
repositoryChange(selectNode, node, process);
break;
}
}
try {
if (!foundInOpen) {
processItem.setProcess(process.saveXmlFile());
factory.save(processItem);
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
} catch (IOException e) {
ExceptionHandler.process(e);
}
}
// ProcessType process = item.getProcess();
// EList<NodeType> nodeList = process.getNode();
//
// for (NodeType node : nodeList) {
// EList parameters = node.getElementParameter();
// for (Object paramObj : parameters) {
// ElementParameterType param = (ElementParameterType) paramObj;
// String name = param.getName();
// if (name.equals(WSDLUtils.OPERATION_NAME)) {
// if (!newOpe.getName().equals(param.getValue())) {
// break;
// }
// param.setValue(null);
// }
// if (name.equals("SCHEMA:SCHEMA_TYPE")) {
// param.setValue("BUILT_IN");
// break;
// }
//
// }
//
// }
// factory.save(item);
}
use of org.talend.core.model.repository.IRepositoryViewObject in project tesb-studio-se by Talend.
the class ESBService method deleteOldRelation.
@Override
public void deleteOldRelation(String jobID) {
boolean portBreak = false;
boolean serviceBreak = false;
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
try {
for (IRepositoryViewObject viewObject : factory.getAll(ERepositoryObjectType.SERVICESOPERATION)) {
ServiceItem serviceItem = (ServiceItem) viewObject.getProperty().getItem();
ServiceConnection serviceConnection = (ServiceConnection) serviceItem.getConnection();
List<ServicePort> ports = serviceConnection.getServicePort();
for (ServicePort port : ports) {
List<ServiceOperation> operations = port.getServiceOperation();
for (ServiceOperation operation : operations) {
String referenceJobId = operation.getReferenceJobId();
if (jobID.equals(referenceJobId)) {
operation.setLabel(operation.getName());
operation.setReferenceJobId(null);
portBreak = true;
break;
}
}
if (portBreak) {
serviceBreak = true;
break;
}
}
if (serviceBreak) {
factory.save(serviceItem, null);
break;
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
use of org.talend.core.model.repository.IRepositoryViewObject in project tdi-studio-se by Talend.
the class JobJavaScriptsManager method getProcessItemPath.
protected IPath getProcessItemPath(ProcessItem processItem, String path, boolean flag, String... selectedJobVersion) throws Exception {
String processPath = processItem.getState().getPath();
if (path != null) {
processPath = path;
}
//$NON-NLS-1$ //$NON-NLS-2$
processPath = processPath == null || processPath.equals("") ? "" : processPath;
IPath emfFileRootPath = getEmfFileRootPath(processItem);
String jobName = processItem.getProperty().getLabel();
String jobVersion = processItem.getProperty().getVersion();
if (!isMultiNodes() && selectedJobVersion != null && selectedJobVersion.length == 1) {
jobVersion = selectedJobVersion[0];
}
IPath itemPath = emfFileRootPath.append(processPath).append(jobName + '_' + jobVersion + '.' + FileConstants.ITEM_EXTENSION);
File itemFile = itemPath.toFile();
if (!flag && !itemFile.exists()) {
IRepositoryViewObject specificVersion = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory().getSpecificVersion(processItem.getProperty().getId(), jobVersion, true);
if (specificVersion != null) {
Property property = specificVersion.getProperty();
URI uri = property.eResource().getURI();
IPath fullPath = URIHelper.convert(uri);
IPath relativePath = fullPath.makeRelativeTo(emfFileRootPath);
String realProcessPath = relativePath.removeLastSegments(1).removeFirstSegments(2).toString();
return getProcessItemPath(processItem, realProcessPath, true, selectedJobVersion);
}
}
return itemPath;
}
use of org.talend.core.model.repository.IRepositoryViewObject in project tdi-studio-se by Talend.
the class JobJavaScriptsManager method addRoutinesSourceCodes.
protected void addRoutinesSourceCodes(ExportFileResource[] process, ExportFileResource resource, ITalendProcessJavaProject talendProcessJavaProject, boolean useBeans) throws Exception {
List<IRepositoryViewObject> collectRoutines = new ArrayList<IRepositoryViewObject>();
String include;
if (useBeans) {
include = USER_BEANS_PATH;
} else {
include = USER_ROUTINES_PATH;
}
collectRoutines.addAll(collectRoutines(process, include));
collectRoutines.addAll(collectRoutines(process, USER_PIGUDF_PATH));
Set<String> dependedRoutines = new HashSet<String>();
for (IRepositoryViewObject obj : collectRoutines) {
dependedRoutines.add(//$NON-NLS-1$
obj.getLabel() + "." + ECodeLanguage.JAVA.getExtension());
}
IFolder srcFolder = talendProcessJavaProject.getSrcFolder();
IFolder folder = null;
if (useBeans) {
folder = srcFolder.getFolder(USER_BEANS_PATH);
} else {
folder = srcFolder.getFolder(JavaUtils.JAVA_ROUTINES_DIRECTORY);
}
List<URL> userRoutinesFileUrls = new ArrayList<URL>();
if (folder.exists()) {
for (IResource fileResource : folder.members()) {
if (fileResource instanceof IFile && ((IFile) fileResource).getFileExtension().equals(ECodeLanguage.JAVA.getExtension()) && dependedRoutines.contains(((IFile) fileResource).getName())) {
userRoutinesFileUrls.add(fileResource.getLocationURI().toURL());
}
}
if (useBeans) {
resource.addResources(JOB_SOURCE_FOLDER_NAME + PATH_SEPARATOR + USER_BEANS_PATH, userRoutinesFileUrls);
} else {
resource.addResources(JOB_SOURCE_FOLDER_NAME + PATH_SEPARATOR + JavaUtils.JAVA_ROUTINES_DIRECTORY, userRoutinesFileUrls);
}
}
}
use of org.talend.core.model.repository.IRepositoryViewObject in project tdi-studio-se by Talend.
the class JobJavaScriptsManager method collectRoutines.
protected Collection<IRepositoryViewObject> collectRoutines(ExportFileResource[] process, String type) {
List<IRepositoryViewObject> toReturn = new ArrayList<IRepositoryViewObject>();
if (USER_BEANS_PATH.equals(type)) {
ERepositoryObjectType beansType = null;
if (GlobalServiceRegister.getDefault().isServiceRegistered(ICamelDesignerCoreService.class)) {
ICamelDesignerCoreService service = (ICamelDesignerCoreService) GlobalServiceRegister.getDefault().getService(ICamelDesignerCoreService.class);
beansType = service.getBeansType();
}
try {
toReturn = ProxyRepositoryFactory.getInstance().getAll(beansType);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
toReturn = Collections.emptyList();
}
} else {
Set<String> allRoutinesNames = new HashSet<String>();
ERepositoryObjectType objectType = ERepositoryObjectType.ROUTINES;
if (USER_PIGUDF_PATH.equals(type)) {
objectType = ERepositoryObjectType.PIG_UDF;
}
if (ERepositoryObjectType.ROUTINES == objectType) {
for (ExportFileResource resource : process) {
if (resource.getItem() instanceof ProcessItem) {
Set<String> routinesNeededForJob = LastGenerationInfo.getInstance().getRoutinesNeededWithSubjobPerJob(resource.getItem().getProperty().getId(), resource.getItem().getProperty().getVersion());
if (routinesNeededForJob != null) {
allRoutinesNames.addAll(routinesNeededForJob);
}
}
}
} else {
for (ExportFileResource resource : process) {
if (resource.getItem() instanceof ProcessItem) {
Set<String> routinesNeededForJob = LastGenerationInfo.getInstance().getPigudfNeededWithSubjobPerJob(resource.getItem().getProperty().getId(), resource.getItem().getProperty().getVersion());
if (routinesNeededForJob != null) {
allRoutinesNames.addAll(routinesNeededForJob);
}
}
}
}
if (allRoutinesNames.isEmpty()) {
toReturn.addAll(RoutinesUtil.getCurrentSystemRoutines());
} else {
toReturn.addAll(collectRoutinesFromRepository(allRoutinesNames, objectType));
}
}
return toReturn;
}
Aggregations