use of org.talend.core.model.repository.RepositoryObject in project tesb-studio-se by Talend.
the class JavaCamelJobScriptsExportWSAction method exportAllReferenceJobs.
private void exportAllReferenceJobs(String routeName, ProcessItem routeProcess) throws InvocationTargetException, InterruptedException {
Set<String> jobPackageNames = new HashSet<String>();
for (NodeType cTalendJob : EmfModelUtils.getComponentsByName(routeProcess, "cTalendJob")) {
// $NON-NLS-1$
String jobId = null;
String jobVersion = null;
String jobContext = null;
for (Object o : cTalendJob.getElementParameter()) {
if (!(o instanceof ElementParameterType)) {
continue;
}
ElementParameterType ept = (ElementParameterType) o;
String eptName = ept.getName();
if ("FROM_EXTERNAL_JAR".equals(eptName) && "true".equals(ept.getValue())) {
// $NON-NLS-1$
break;
}
if ("SELECTED_JOB_NAME:PROCESS_TYPE_PROCESS".equals(eptName)) {
// $NON-NLS-1$
jobId = ept.getValue();
} else if ("SELECTED_JOB_NAME:PROCESS_TYPE_VERSION".equals(eptName)) {
// $NON-NLS-1$
jobVersion = ept.getValue();
} else if ("SELECTED_JOB_NAME:PROCESS_TYPE_CONTEXT".equals(eptName)) {
// $NON-NLS-1$
jobContext = ept.getValue();
}
}
if (jobId == null || jobVersion == null) {
continue;
}
IRepositoryViewObject repositoryObject;
Project jobProject;
try {
repositoryObject = getJobRepositoryNode(jobId, ERepositoryObjectType.PROCESS);
jobProject = getJobProject(jobId, ERepositoryObjectType.PROCESS);
} catch (PersistenceException e) {
throw new InvocationTargetException(e);
}
if (RelationshipItemBuilder.LATEST_VERSION.equals(jobVersion)) {
jobVersion = repositoryObject.getVersion();
}
String jobName = repositoryObject.getProperty().getDisplayName();
String jobBundleName = routeName + "_" + jobName;
String jobBundleSymbolicName = jobBundleName;
String jobPackageName = getJobPackageName(jobProject, jobName, jobVersion);
if (!jobPackageNames.contains(jobPackageName)) {
jobPackageNames.add(jobPackageName);
}
Project project = ProjectManager.getInstance().getCurrentProject();
if (project != null) {
String projectName = project.getLabel();
if (projectName != null && projectName.length() > 0) {
jobBundleSymbolicName = projectName.toLowerCase() + '.' + jobBundleSymbolicName;
}
}
File jobFile;
try {
// $NON-NLS-1$
jobFile = File.createTempFile("job", FileConstants.JAR_FILE_SUFFIX, new File(getTempDir()));
addBuildArtifact(repositoryObject, "jar", jobFile);
} catch (IOException e) {
throw new InvocationTargetException(e);
}
String jobBundleVersion = buildBundleVersionForReferencedJob(routeProcess, jobId);
String jobArtifactVersion = jobBundleVersion;
String jobGroup = (String) routeProcess.getProperty().getAdditionalProperties().get(BUILD_FROM_COMMANDLINE_GROUP);
if (jobGroup == null) {
jobGroup = PomIdsHelper.getJobGroupId(routeProcess.getProperty());
}
BundleModel jobModel = new BundleModel(jobGroup, jobBundleName, jobBundleVersion, jobFile);
if (featuresModel.getBundles().contains(jobModel)) {
featuresModel.getBundles().remove(jobModel);
}
if (featuresModel.addBundle(jobModel)) {
exportRouteUsedJobBundle(repositoryObject, jobFile, jobVersion, jobBundleName, jobBundleSymbolicName, jobArtifactVersion.replace("-", "."), getArtifactId(), version, jobContext);
}
}
addJobPackageToOsgiImport(routeProcess, jobPackageNames);
}
use of org.talend.core.model.repository.RepositoryObject in project tesb-studio-se by Talend.
the class JavaCamelJobScriptsExportWSAction method getJobRepositoryNode.
private static IRepositoryViewObject getJobRepositoryNode(String jobId, ERepositoryObjectType type) throws PersistenceException {
String projectLable = ProcessUtils.getProjectLabelFromItemId(jobId);
List<IRepositoryViewObject> list = new ArrayList<>();
List<Project> projects = ProjectManager.getInstance().getAllReferencedProjects();
for (Project p : projects) {
list.addAll(ProxyRepositoryFactory.getInstance().getAll(p, type));
}
list.addAll(ProxyRepositoryFactory.getInstance().getAll(type));
for (IRepositoryViewObject job : list) {
if (job.getId().equals(jobId)) {
if (projectLable == null || StringUtils.equals(projectLable, job.getProjectLabel())) {
return new RepositoryObject(job.getProperty());
}
}
}
return null;
}
Aggregations