Skip to content

Instantly share code, notes, and snippets.

@Genzer
Created August 2, 2016 09:25
Show Gist options
  • Save Genzer/b10ea3dd2100f4839e567c3d91d38d1e to your computer and use it in GitHub Desktop.
Save Genzer/b10ea3dd2100f4839e567c3d91d38d1e to your computer and use it in GitHub Desktop.
Obtain all CMSes from RELEASED `IProcessModelVersion`.
class LoadAllReachableCmsesCommand implements Callable<Set<IContentManagementSystem>> {
@Override
public Set<IContentManagementSystem> call() throws Exception {
Set<IContentManagementSystem> cmses = new HashSet<>();
for (IProcessModelVersion pmv : allReachablePmvs()) {
IContentManagementSystem cms = Ivy.cms()
.getContentManagement().findCms(pmv);
if (cms != null) {
cmses.add(cms);
}
}
return cmses;
}
private List<IProcessModelVersion> allReachablePmvs() {
List<IProcessModelVersion> pmvs = new ArrayList<>();
for (IProcessModel pm : Ivy.wf().getApplication().getProcessModels()) {
IProcessModelVersion releasedPmv = pm.getReleasedProcessModelVersion();
if (releasedPmv != null) {
pmvs.add(releasedPmv);
}
}
return pmvs;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment