Its basically possible if you analyze the RoleConfiguration-Model of active PMVs in an application. The problem is, that the classes are not available in the designer. But you could use them if you add the jar from the engine to classpath (lib/ivy/ch.ivyteam.ivy.user.role_xxx.jar).
I've wrote a sample snip which reads the already deployed role configurations of an app. Don't asume that it is 100% correct and fancy. But you get a hint which APIs that are relevant.

package ch.ivyteam.test;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
import org.eclipse.core.resources.IProject;
import ch.ivyteam.ivy.application.ActivityState;
import ch.ivyteam.ivy.application.IProcessModel;
import ch.ivyteam.ivy.application.IProcessModelVersion;
import ch.ivyteam.ivy.application.ReleaseState;
import ch.ivyteam.ivy.environment.Ivy;
import ch.ivyteam.ivy.project.IIvyProject;
import ch.ivyteam.ivy.resource.datamodel.ResourceDataModelException;
import ch.ivyteam.ivy.role.IRole;
import ch.ivyteam.ivy.role.IRoleConfiguration;
public class ReadPmvRoles {
public static void readAndLog() {
for (IProcessModelVersion pmv : getPmvs()) {
IRoleConfiguration roleConfig = getRoleConfiguration(pmv);
List<String> roleIds = getRoleIds(roleConfig);
Ivy.log().info(pmv+":"+roleIds);
}
}
private static List<String> getRoleIds(IRoleConfiguration roleConfig) {
List<String> roles = new ArrayList<>();
IRole rootRole = roleConfig.getRootRole();
roles.add(rootRole.getIdentifier());
for(IRole childRole : rootRole.getSubRoles())
{
roles.add(childRole.getIdentifier());
}
return roles;
}
private static IRoleConfiguration getRoleConfiguration(IProcessModelVersion pmv) {
IIvyProject project = (IIvyProject) pmv.getProject().getAdapter(
IIvyProject.class);
try {
Set<IRoleConfiguration> roles = project.getProjectRoleConfigurationManager().getRoleModels(null);
return roles.iterator().next();
} catch (ResourceDataModelException ex) {
throw new RuntimeException("can not read role config of " + pmv);
}
}
private static List<IProcessModelVersion> getPmvs() {
List<IProcessModelVersion> activePmvs = new ArrayList<>();
List<IProcessModel> models = Ivy.request().getApplication().getProcessModels();
for (IProcessModel model : models) {
for (IProcessModelVersion pmv : model.getProcessModelVersions()) {
EnumSet<ReleaseState> runningTaskStates = EnumSet.of(
ReleaseState.RELEASED, ReleaseState.DEPRECATED);
if (runningTaskStates.contains(pmv.getReleaseState())) {
activePmvs.add(pmv);
}
}
}
return activePmvs;
}
}
answered
05.03.2015 at 11:24
Reguel Werme... ♦♦
9.4k●3●19●58
accept rate:
70%