Compare commits

...

5 Commits

Author SHA1 Message Date
apoltavtsev
fcd87908ce Update PomIdsHelper.java 2020-10-12 12:33:35 +02:00
apoltavtsev
e8e0002aa7 Update AbstractMavenProcessorPom.java 2020-10-11 20:13:27 +02:00
apoltavtsev
a7580e0ee3 Update JobUtils.java 2020-10-11 20:11:40 +02:00
apoltavtsev
b13dc822ec Update AbstractMavenProcessorPom.java 2020-10-11 19:36:02 +02:00
apoltavtsev
82a487b9e7 fix(TESB-29553) Publishing a route with cTalendJob from Studio and commandline gives different results 2020-10-01 09:52:28 +02:00
4 changed files with 51 additions and 3 deletions

View File

@@ -1003,4 +1003,12 @@ public final class ProcessUtils {
}
return false;
}
public static boolean isChildRouteProcess(IProcess process) {
List n = process.getNodesOfType("tRouteInput");
if (n!=null && n.size()!=0) {
return true;
}
return false;
}
}

View File

@@ -45,6 +45,7 @@ import org.talend.core.model.utils.JavaResourcesHelper;
import org.talend.core.runtime.maven.MavenArtifact;
import org.talend.core.runtime.maven.MavenConstants;
import org.talend.core.runtime.maven.MavenUrlHelper;
import org.talend.core.runtime.process.LastGenerationInfo;
import org.talend.core.runtime.process.TalendProcessArgumentConstant;
import org.talend.core.runtime.projectsetting.IProjectSettingTemplateConstants;
import org.talend.core.runtime.repository.build.IMavenPomCreator;
@@ -52,6 +53,7 @@ import org.talend.core.ui.ITestContainerProviderService;
import org.talend.designer.maven.model.TalendMavenConstants;
import org.talend.designer.maven.template.ETalendMavenVariables;
import org.talend.designer.maven.tools.ProcessorDependenciesManager;
import org.talend.designer.maven.utils.JobUtils;
import org.talend.designer.maven.utils.PomIdsHelper;
import org.talend.designer.maven.utils.PomUtil;
import org.talend.designer.runprocess.IBigDataProcessor;
@@ -134,9 +136,16 @@ public abstract class AbstractMavenProcessorPom extends CreateMavenBundleTemplat
Map<ETalendMavenVariables, String> variablesValuesMap = new HashMap<ETalendMavenVariables, String>();
// no need check property is null or not, because if null, will get default ids.
variablesValuesMap.put(ETalendMavenVariables.JobGroupId, PomIdsHelper.getJobGroupId(property));
variablesValuesMap.put(ETalendMavenVariables.JobArtifactId, PomIdsHelper.getJobArtifactId(property));
variablesValuesMap.put(ETalendMavenVariables.JobVersion, PomIdsHelper.getJobVersion(property));
if (JobUtils.isJob(property) && ProcessUtils.isChildRouteProcess(process)) {
JobInfo lastMainJob = LastGenerationInfo.getInstance().getLastMainJob();
variablesValuesMap.put(ETalendMavenVariables.JobGroupId, PomIdsHelper.getJobGroupId(lastMainJob.getProcessor().getProperty()));
variablesValuesMap.put(ETalendMavenVariables.JobVersion, PomIdsHelper.getJobVersion(lastMainJob.getProcessor().getProperty()));
}else {
variablesValuesMap.put(ETalendMavenVariables.JobGroupId, PomIdsHelper.getJobGroupId(property));
variablesValuesMap.put(ETalendMavenVariables.JobVersion, PomIdsHelper.getJobVersion(property));
}
variablesValuesMap.put(ETalendMavenVariables.JobArtifactId, PomIdsHelper.getJobArtifactId(property));
variablesValuesMap.put(ETalendMavenVariables.TalendJobVersion, property.getVersion());
final String jobName = JavaResourcesHelper.escapeFileName(process.getName());
variablesValuesMap.put(ETalendMavenVariables.JobName, jobName);

View File

@@ -19,11 +19,14 @@ import java.util.Set;
import org.talend.commons.exception.PersistenceException;
import org.talend.core.GlobalServiceRegister;
import org.talend.core.model.process.INode;
import org.talend.core.model.process.IProcess;
import org.talend.core.model.process.JobInfo;
import org.talend.core.model.process.ProcessUtils;
import org.talend.core.model.properties.Item;
import org.talend.core.model.properties.ProcessItem;
import org.talend.core.model.properties.Property;
import org.talend.core.model.repository.ERepositoryObjectType;
import org.talend.core.model.repository.IRepositoryViewObject;
import org.talend.core.model.utils.JavaResourcesHelper;
import org.talend.core.runtime.CoreRuntimePlugin;
@@ -97,5 +100,22 @@ public class JobUtils {
}
return clonedJobInfos;
}
public static boolean isJob(JobInfo job) {
if (job != null && job.getProcessItem() != null) {
Property p = job.getProcessItem().getProperty();
if (p != null) {
return isJob(p);
}
}
return false;
}
public static boolean isJob(Property p) {
if (p != null) {
return ERepositoryObjectType.getType(p).equals(ERepositoryObjectType.PROCESS);
}
return false;
}
}

View File

@@ -247,6 +247,17 @@ public class PomIdsHelper {
return version;
}
public static String getCustomJobVersion(Property property) {
String version = null;
if (property != null) {
if (property.getAdditionalProperties() != null) {
version = (String) property.getAdditionalProperties().get(MavenConstants.NAME_USER_VERSION);
}
}
return version;
}
public static String getJobVersion(JobInfo jobInfo) {
if (jobInfo != null) {
return jobInfo.getJobVersion();