Hello Dani
This is currently not possible by using public API.
Anyway I have just improved the startref-method, that it searchs in required projects too. This improvement will be available with the next version (6.4) and is tracked on
issue XIVY-1322: ivy.html.startref() should also generate link for process starts in required projects
In the meanwhile you could use the below utility. Please note, that this code make use of NON-Public API and will eventually not work in further releases. Therefore, as soon the next release is avaiable, replace this code with the call to the regular public API.
package util;
import java.net.URI;
import ch.ivyteam.ivy.environment.Ivy;
import ch.ivyteam.ivy.persistence.PersistencyException;
import ch.ivyteam.ivy.project.IIvyProject;
import ch.ivyteam.ivy.request.IHttpProcessModelVersionRequest;
import ch.ivyteam.ivy.request.IHttpRequest;
import ch.ivyteam.ivy.request.RequestUriFactory;
import ch.ivyteam.ivy.security.SecurityManagerFactory;
import ch.ivyteam.ivy.workflow.IStartElement;
import ch.ivyteam.ivy.workflow.IWorkflowProcessModelVersion;
@SuppressWarnings("restriction")
public class HtmlContextUtils {
public static String startref(final String startName) {
try {
IStartElement start = findStartElement(startName);
if (start != null) {
URI processStartUri = RequestUriFactory.createProcessStartUri((IHttpProcessModelVersionRequest) Ivy.request(), start);
return makeUriAbsolute(processStartUri).toASCIIString();
}
} catch (PersistencyException ex) {
Ivy.log().error(ex);
}
return "";
}
private static IStartElement findStartElement(final String startName) {
return SecurityManagerFactory.getSecurityManager().executeAsSystem2(() -> {
IIvyProject project = Ivy.request().getProject();
IStartElement startElement = findStartElement(startName, project);
if (startElement != null) {
return startElement;
}
for (IIvyProject ivyProject : project.getRequiredProjects()) {
startElement = findStartElement(startName, ivyProject);
if (startElement != null) {
return startElement;
}
}
return null;
});
}
private static IStartElement findStartElement(final String startName, IIvyProject ivyProject) {
IWorkflowProcessModelVersion wpmv = ivyProject.getWorkflowProcessModelVersion();
IStartElement startElement = wpmv.findStartElement(startName);
if (startElement == null) {
startElement = wpmv.findStartElementByUserFriendlyRequestPath(startName);
}
return startElement;
}
private static URI makeUriAbsolute(URI uri) {
if (uri.isAbsolute()) {
return uri;
}
return RequestUriFactory.createServerUri((IHttpRequest) Ivy.request()).resolve(uri);
}
}
answered
12.09.2016 at 15:16
Flavio Sadeghi ♦♦
(suspended)
accept rate:
75%
Any Ideas?