use of org.talend.commons.exception.PersistenceException in project tesb-studio-se by Talend.
the class JavaCamelJobScriptsExportWSAction method exportAllReferenceRoutelets.
@SuppressWarnings("unchecked")
protected final void exportAllReferenceRoutelets(String routeName, ProcessItem routeProcess, Set<String> routelets) throws InvocationTargetException, InterruptedException {
for (NodeType node : (Collection<NodeType>) routeProcess.getProcess().getNode()) {
if (!EmfModelUtils.isComponentActive(node)) {
continue;
}
final ElementParameterType routeletId = EmfModelUtils.findElementParameterByName(EParameterName.PROCESS_TYPE.getName() + ':' + EParameterName.PROCESS_TYPE_PROCESS.getName(), node);
if (null != routeletId) {
final IRepositoryNode referencedRouteletNode;
try {
referencedRouteletNode = getJobRepositoryNode(routeletId.getValue(), CamelRepositoryNodeType.repositoryRouteletType);
// getRouteletRepositoryNode(routeletId);
} catch (PersistenceException e) {
throw new InvocationTargetException(e);
}
final ProcessItem routeletProcess = (ProcessItem) referencedRouteletNode.getObject().getProperty().getItem();
final String className = RouteJavaScriptOSGIForESBManager.getClassName(routeletProcess);
String idSuffix = "-" + routeName;
if (!routelets.add(className + idSuffix)) {
continue;
}
String routeletVersion = EmfModelUtils.findElementParameterByName(EParameterName.PROCESS_TYPE.getName() + ':' + EParameterName.PROCESS_TYPE_VERSION.getName(), node).getValue();
if (RelationshipItemBuilder.LATEST_VERSION.equals(routeletVersion)) {
routeletVersion = referencedRouteletNode.getObject().getVersion();
}
final File routeletFile;
try {
routeletFile = File.createTempFile("routelet", FileConstants.JAR_FILE_SUFFIX, //$NON-NLS-1$
new File(getTempDir()));
} catch (IOException e) {
throw new InvocationTargetException(e);
}
String routeletName = referencedRouteletNode.getObject().getLabel();
String routeletBundleName = routeName + "_" + routeletName;
String routeletBundleSymbolicName = routeletBundleName;
Project project = ProjectManager.getInstance().getCurrentProject();
if (project != null) {
String projectName = project.getLabel();
if (projectName != null && projectName.length() > 0) {
routeletBundleSymbolicName = projectName.toLowerCase() + '.' + routeletBundleSymbolicName;
}
}
BundleModel routeletModel = new BundleModel(getGroupId(), routeletBundleName, getArtifactVersion(), routeletFile);
if (featuresModel.addBundle(routeletModel)) {
exportRouteBundle(referencedRouteletNode, routeletFile, routeletVersion, routeletBundleName, routeletBundleSymbolicName, bundleVersion, idSuffix, null, EmfModelUtils.findElementParameterByName(EParameterName.PROCESS_TYPE.getName() + ':' + EParameterName.PROCESS_TYPE_CONTEXT.getName(), node).getValue());
CamelFeatureUtil.addFeatureAndBundles(routeletProcess, featuresModel);
exportAllReferenceRoutelets(routeName, routeletProcess, routelets);
}
}
}
}
use of org.talend.commons.exception.PersistenceException in project tesb-studio-se by Talend.
the class ResourceDependencyModel method getVersions.
/**
* @return the versions
*/
public Collection<String> getVersions() {
final List<String> versions = new ArrayList<String>();
try {
for (IRepositoryViewObject obj : ProxyRepositoryFactory.getInstance().getAllVersion(item.getProperty().getId())) {
versions.add(obj.getVersion());
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
versions.add(LATEST_VERSION);
Collections.sort(versions);
return versions;
}
use of org.talend.commons.exception.PersistenceException in project tesb-studio-se by Talend.
the class RouteResourceUtil method createDependency.
/**
*
* @param id
* @param version
* @return
*/
public static ResourceDependencyModel createDependency(String id, String version) {
try {
final IRepositoryViewObject rvo;
if (ResourceDependencyModel.LATEST_VERSION.equals(version)) {
rvo = ProxyRepositoryFactory.getInstance().getLastVersion(id);
} else {
rvo = ProxyRepositoryFactory.getInstance().getSpecificVersion(id, version, true);
}
if (rvo != null) {
final ResourceDependencyModel model = new ResourceDependencyModel((RouteResourceItem) rvo.getProperty().getItem());
model.setSelectedVersion(version);
return model;
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
return null;
}
use of org.talend.commons.exception.PersistenceException in project tesb-studio-se by Talend.
the class LocalWSDLEditor method saveModel.
private void saveModel() throws CoreException {
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
Definition definition = WSDLUtils.getDefinition(serviceItem);
// changed for TDI-18005
Map<String, String> portNameIdMap = new HashMap<String, String>();
Map<String, EMap<String, String>> portAdditionalMap = new HashMap<String, EMap<String, String>>();
Map<String, String> operNameIdMap = new HashMap<String, String>();
Map<String, String> operJobMap = new HashMap<String, String>();
EList<ServicePort> oldServicePorts = ((ServiceConnection) serviceItem.getConnection()).getServicePort();
// get old service port item names and operation names under them
HashMap<String, ArrayList<String>> oldPortItemNames = new HashMap<String, ArrayList<String>>();
for (ServicePort servicePort : oldServicePorts) {
// keep id
portNameIdMap.put(servicePort.getName(), servicePort.getId());
// keep additional infos
portAdditionalMap.put(servicePort.getId(), servicePort.getAdditionalInfo());
EList<ServiceOperation> operations = servicePort.getServiceOperation();
ArrayList<String> operationNames = new ArrayList<String>();
for (ServiceOperation operation : operations) {
operNameIdMap.put(operation.getName(), operation.getId());
operationNames.add(operation.getLabel());
// record assigned job
operJobMap.put(operation.getId(), operation.getReferenceJobId());
}
oldPortItemNames.put(servicePort.getName(), operationNames);
}
((ServiceConnection) serviceItem.getConnection()).getServicePort().clear();
for (Object obj : definition.getAllPortTypes().values()) {
PortType portType = (PortType) obj;
if (portType.isUndefined()) {
continue;
}
ServicePort port = ServicesFactory.eINSTANCE.createServicePort();
String portName = portType.getQName().getLocalPart();
port.setName(portName);
// set port id
String id = portNameIdMap.get(portName);
if (id != null) {
port.setId(id);
// restore additional infos
port.getAdditionalInfo().putAll(portAdditionalMap.get(id));
} else {
port.setId(factory.getNextId());
}
@SuppressWarnings("unchecked") List<Operation> list = portType.getOperations();
for (Operation operation : list) {
if (operation.isUndefined()) {
// means the operation has been removed already ,why ?
continue;
}
ServiceOperation serviceOperation = ServicesFactory.eINSTANCE.createServiceOperation();
serviceOperation.setName(operation.getName());
Iterator<String> operationIterator = operNameIdMap.keySet().iterator();
while (operationIterator.hasNext()) {
String oldOperationName = operationIterator.next();
String operationId = operNameIdMap.get(oldOperationName);
if (oldOperationName.equals(operation.getName())) {
serviceOperation.setId(operationId);
// re-assign job
String jobId = operJobMap.get(operationId);
if (jobId != null) {
serviceOperation.setReferenceJobId(jobId);
}
}
}
if (serviceOperation.getId() == null || serviceOperation.getId().equals("")) {
serviceOperation.setId(factory.getNextId());
}
if (operation.getDocumentationElement() != null) {
serviceOperation.setDocumentation(operation.getDocumentationElement().getTextContent());
}
boolean hasAssignedjob = false;
ArrayList<String> operationNames = oldPortItemNames.get(portName);
String referenceJobId = serviceOperation.getReferenceJobId();
if (operationNames != null && referenceJobId != null) {
IRepositoryViewObject repObj = null;
try {
repObj = factory.getLastVersion(referenceJobId);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
if (repObj != null) {
for (String name : operationNames) {
if (name.equals(operation.getName() + '-' + repObj.getLabel())) {
serviceOperation.setLabel(name);
hasAssignedjob = true;
break;
}
}
}
}
if (!hasAssignedjob) {
serviceOperation.setLabel(operation.getName());
}
serviceOperation.setInBinding(WSDLUtils.isOperationInBinding(definition, portName, operation.getName()));
port.getServiceOperation().add(serviceOperation);
}
((ServiceConnection) serviceItem.getConnection()).getServicePort().add(port);
}
}
use of org.talend.commons.exception.PersistenceException in project tesb-studio-se by Talend.
the class ServiceExportWithMavenManager method analysisMavenModule.
@Override
protected void analysisMavenModule(Item item) {
if (item != null && item instanceof ServiceItem) {
try {
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
List<String> mavenModules = getMavenModules();
ServiceItem serviceItem = (ServiceItem) item;
ServiceConnection connection = (ServiceConnection) serviceItem.getConnection();
EList<ServicePort> listPort = connection.getServicePort();
for (ServicePort port : listPort) {
List<ServiceOperation> listOperation = port.getServiceOperation();
for (ServiceOperation operation : listOperation) {
if (StringUtils.isNotEmpty(operation.getReferenceJobId())) {
IRepositoryViewObject repObj = factory.getLastVersion(operation.getReferenceJobId());
if (repObj != null) {
String jobName = repObj.getLabel();
if (jobName != null && !mavenModules.contains(jobName)) {
mavenModules.add(OPERATIONS_PATH + jobName);
}
}
}
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
}
Aggregations