/** * Obtain a DcsRelationship from a string representation. May return <code>null</code> if the type isn't supported. * * @param relType a string representing the relationship type * @return the DcsRelationship or <code>null</code> if it isn't supported. */ public static DcsRelationship fromString(String relType) { for (DcsRelationship value : values()) { if (value.asString().equals(relType)) { return value; } } return null; } }
private java.util.Collection<DcsEntity> filterForLatestDeliverableUnits(java.util.Collection<? extends DcsEntity> entities) { java.util.Collection<DcsEntity> result = new HashSet<DcsEntity>(); List<String> predecessorDuIds = new ArrayList<String>(); for (DcsEntity entity : entities) { if (!(entity instanceof DcsDeliverableUnit)) { continue; } DcsDeliverableUnit du = (DcsDeliverableUnit)entity; for (DcsRelation rel : du.getRelations()) { if (rel.getRelUri().equals(DcsRelationship.IS_SUCCESSOR_OF.asString())) { predecessorDuIds.add(rel.getRef().getRef()); } } } for (DcsEntity entity : entities) { if (!(entity instanceof DcsDeliverableUnit)) { result.add(entity); continue; } DcsDeliverableUnit du = (DcsDeliverableUnit) entity; if (!predecessorDuIds.contains(du.getId())) { result.add(du); } } return result; }
/** * Creates a DcsRelationship with a relationship type of <code>rel</code> with <code>target</code>. See * {@link DcsRelationship} for supported relationship types. * * @param rel the relationship type, must not be <code>null</code> * @param target the target entity, must not be empty or <code>null</code> */ public DcsRelation(DcsRelationship rel, String target) { Assertion.notNull(rel); Assertion.notEmptyOrNull(target); this.relUri = rel.asString(); this.ref = new DcsEntityReference(target); }
private java.util.Collection<DcsEntity> filterForLatestDeliverableUnits(java.util.Collection<? extends DcsEntity> entities) { java.util.Collection<DcsEntity> result = new HashSet<DcsEntity>(); List<String> predecessorDuIds = new ArrayList<String>(); for (DcsEntity entity : entities) { if (!(entity instanceof DcsDeliverableUnit)) { continue; } DcsDeliverableUnit du = (DcsDeliverableUnit)entity; for (DcsRelation rel : du.getRelations()) { if (rel.getRelUri().equals(DcsRelationship.IS_SUCCESSOR_OF.asString())) { predecessorDuIds.add(rel.getRef().getRef()); } } } for (DcsEntity entity : entities) { if (!(entity instanceof DcsDeliverableUnit)) { result.add(entity); continue; } DcsDeliverableUnit du = (DcsDeliverableUnit) entity; if (!predecessorDuIds.contains(du.getId())) { result.add(du); } } return result; }
/** * Creates a DcsRelationship with a relationship type of <code>relUri</code> with <code>target</code>. See * {@link DcsRelationship} for supported relationship types. * * @param rel the relationship type, must not be <code>null</code> * @param target the target entity, must not be <code>null</code> */ public DcsRelation(DcsRelationship rel, DcsEntityReference target) { Assertion.notNull(rel); Assertion.notNull(target); this.relUri = rel.asString(); this.ref = new DcsEntityReference(target); }
String getPredecessorId(DcsDeliverableUnit du) { for (DcsRelation rel : du.getRelations()) { if (rel.getRelUri().equals(DcsRelationship.IS_SUCCESSOR_OF.asString())) { if (rel.getRef() == null || rel.getRef().getRef() == null) { return null; } return rel.getRef().getRef(); } } return null; }
String getPredecessorId(DcsDeliverableUnit du) { for (DcsRelation rel : du.getRelations()) { if (rel.getRelUri().equals(DcsRelationship.IS_SUCCESSOR_OF.asString())) { if (rel.getRef() == null || rel.getRef().getRef() == null) { return null; } return rel.getRef().getRef(); } } return null; }
String getPredecessorId(DcsDeliverableUnit du) { for (DcsRelation rel : du.getRelations()) { if (rel.getRelUri().equals(DcsRelationship.IS_SUCCESSOR_OF.asString())) { if (rel.getRef() == null || rel.getRef().getRef() == null) { return null; } return rel.getRef().getRef(); } } return null; }
private String getPredecessorId(DcsDeliverableUnit du) { for (DcsRelation rel : du.getRelations()) { if (rel.getRelUri().equals( DcsRelationship.IS_SUCCESSOR_OF.asString())) { if (rel.getRef() == null || rel.getRef().getRef() == null) { return null; } return rel.getRef().getRef(); } } return null; }
/** * Returns the identifier of the predecessor of the supplied {@code du}, or null if the DU has no predecessors. * * @param du the deliverable unit * @return the identifier of the predecessor, or null */ public String getPredecessorId(DcsDeliverableUnit du) { for (DcsRelation rel : du.getRelations()) { if (rel.getRelUri().equals( DcsRelationship.IS_SUCCESSOR_OF.asString())) { if (rel.getRef() == null || rel.getRef().getRef() == null) { return null; } return rel.getRef().getRef(); } } return null; }
/** * Returns the identifier of the predecessor of the supplied {@code du}, or null if the DU has no predecessors. * * @param du the deliverable unit * @return the identifier of the predecessor, or null */ public String getPredecessorId(DcsDeliverableUnit du) { for (DcsRelation rel : du.getRelations()) { if (rel.getRelUri().equals( DcsRelationship.IS_SUCCESSOR_OF.asString())) { if (rel.getRef() == null || rel.getRef().getRef() == null) { return null; } return rel.getRef().getRef(); } } return null; }
rel.setRelUri(DcsRelationship.IS_SUCCESSOR_OF.asString());