use of org.talend.core.model.general.Project in project tdi-studio-se by Talend.
the class JSONFileOutputStep1Form method initFileContent.
private void initFileContent() {
if (getConnection().getJSONFilePath() == null || "".equals(getConnection().getJSONFilePath())) {
return;
}
byte[] bytes = getConnection().getFileContent();
Project project = ProjectManager.getInstance().getCurrentProject();
IProject fsProject = null;
try {
fsProject = ResourceUtils.getProject(project);
} catch (PersistenceException e2) {
ExceptionHandler.process(e2);
}
if (fsProject == null) {
return;
}
String tem = fsProject.getLocationURI().getPath() + File.separator + "temp";
String fileName = "";
String jsonPath = getConnection().getJSONFilePath();
if (isContextMode()) {
ContextType contextType = ConnectionContextHelper.getContextTypeForContextMode(connectionItem.getConnection());
jsonPath = TalendQuoteUtils.removeQuotes(ConnectionContextHelper.getOriginalValue(contextType, jsonPath));
}
if (jsonPath != null && jsonPath.contains(".zip")) {
fileName = new Path(jsonPath).lastSegment();
} else if (jsonPath != null) {
fileName = JSONUtil.TMP_JSON_FILE;
}
File temfile = new File(tem + File.separator + fileName);
if (!temfile.exists()) {
try {
temfile.createNewFile();
} catch (IOException e) {
ExceptionHandler.process(e);
}
}
FileOutputStream outStream;
try {
outStream = new FileOutputStream(temfile);
outStream.write(bytes);
outStream.close();
} catch (FileNotFoundException e1) {
ExceptionHandler.process(e1);
} catch (IOException e) {
ExceptionHandler.process(e);
}
tempJSONPath = temfile.getPath();
if (isContextMode()) {
ContextType contextType = ConnectionContextHelper.getContextTypeForContextMode(connectionItem.getConnection());
tempJSONPath = TalendQuoteUtils.removeQuotes(ConnectionContextHelper.getOriginalValue(contextType, tempJSONPath));
}
// valid = this.treePopulator.populateTree(tempJSONXsdPath, treeNode);
}
use of org.talend.core.model.general.Project in project tdi-studio-se by Talend.
the class JarBuilder method getTmpFolderPath.
private String getTmpFolderPath() {
Project project = ProjectManager.getInstance().getCurrentProject();
String tmpFolder;
try {
IProject physProject = ResourceModelUtils.getProject(project);
tmpFolder = physProject.getFolder(TEMP).getLocation().toPortableString();
} catch (Exception e) {
//$NON-NLS-1$
tmpFolder = System.getProperty("user.dir");
}
//$NON-NLS-1$
tmpFolder = tmpFolder + "/talendExporter";
return tmpFolder;
}
use of org.talend.core.model.general.Project in project tesb-studio-se by Talend.
the class JavaCamelJobScriptsExportWSAction method getJobRepositoryNode.
private static IRepositoryNode getJobRepositoryNode(String jobId, ERepositoryObjectType type) throws PersistenceException {
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)) {
return new RepositoryNode(job, null, ENodeType.REPOSITORY_ELEMENT);
}
}
return null;
}
use of org.talend.core.model.general.Project in project tesb-studio-se by Talend.
the class JavaCamelJobScriptsExportWSAction method exportAllReferenceJobs.
private void exportAllReferenceJobs(String routeName, ProcessItem routeProcess) throws InvocationTargetException, InterruptedException {
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;
}
IRepositoryNode referencedJobNode;
try {
referencedJobNode = getJobRepositoryNode(jobId, ERepositoryObjectType.PROCESS);
} catch (PersistenceException e) {
throw new InvocationTargetException(e);
}
if (RelationshipItemBuilder.LATEST_VERSION.equals(jobVersion)) {
jobVersion = referencedJobNode.getObject().getVersion();
}
String jobName = referencedJobNode.getObject().getProperty().getDisplayName();
String jobBundleName = routeName + "_" + jobName;
String jobBundleSymbolicName = jobBundleName;
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 {
jobFile = File.createTempFile("job", FileConstants.JAR_FILE_SUFFIX, //$NON-NLS-1$
new File(getTempDir()));
} catch (IOException e) {
throw new InvocationTargetException(e);
}
String jobArtifactVersion = getArtifactVersion();
String jobBundleVersion = bundleVersion;
BundleModel jobModel = new BundleModel(getGroupId(), jobBundleName, jobArtifactVersion, jobFile);
if (featuresModel.addBundle(jobModel)) {
exportRouteUsedJobBundle(referencedJobNode, jobFile, jobVersion, jobBundleName, jobBundleSymbolicName, jobBundleVersion, getArtifactId(), version, jobContext);
}
}
}
Aggregations