public PdcClassification build() {
    ClassificationPlan pdc = aClassificationPlan();
    List<ClassifyPosition> positions = new ArrayList<ClassifyPosition>();

    List<ClassifyValue> positionValues = new ArrayList<ClassifyValue>();
    List<Value> values = pdc.getValuesOfAxisByName("Pays");
    Value value = findTerm("Grenoble", values);
    ClassifyValue classifyValue =
        new ClassifyValue(toValueId(value.getAxisId()), toValue(value.getFullPath()));
    classifyValue.setFullPath(pdc.getPathInTreeOfValue(value));
    positionValues.add(classifyValue);
    values = pdc.getValuesOfAxisByName("Période");
    value = findTerm("Moyen-Age", values);
    classifyValue = new ClassifyValue(toValueId(value.getAxisId()), toValue(value.getFullPath()));
    classifyValue.setFullPath(pdc.getPathInTreeOfValue(value));
    positionValues.add(classifyValue);
    positions.add(new ClassifyPosition(positionValues));

    positionValues = new ArrayList<ClassifyValue>();
    values = pdc.getValuesOfAxisByName("Religion");
    value = findTerm("Christianisme", values);
    classifyValue = new ClassifyValue(toValueId(value.getAxisId()), toValue(value.getFullPath()));
    classifyValue.setFullPath(pdc.getPathInTreeOfValue(value));
    positionValues.add(classifyValue);
    positions.add(new ClassifyPosition(positionValues));

    PdcClassification classification =
        aClassificationFromPositions(positions).inComponentInstance(getComponentId());
    if (getContentId() != null) {
      classification = classification.ofContent(getContentId());
    } else if (getNodeId() != null) {
      classification = classification.forNode(getNodeId());
    }
    return classification;
  }
  public PdcClassification buildWithNoSynonyms() {
    ClassificationPlan pdc = aClassificationPlan();
    List<ClassifyPosition> positions = new ArrayList<ClassifyPosition>();

    List<ClassifyValue> positionValues = new ArrayList<ClassifyValue>();
    List<Value> values = pdc.getValuesOfAxisByName("Technologie");
    Value value = values.get(0);
    ClassifyValue classifyValue =
        new ClassifyValue(toValueId(value.getAxisId()), toValue(value.getFullPath()));
    classifyValue.setFullPath(pdc.getPathInTreeOfValue(value));
    positionValues.add(classifyValue);
    positions.add(new ClassifyPosition(positionValues));

    return aClassificationFromPositions(positions)
        .ofContent(contentId)
        .inComponentInstance(componentId);
  }
Exemplo n.º 3
0
 @Override
 public List<Value> getPertinentDaughterValuesByInstanceIds(
     SearchContext searchContext, String axisId, String valueId, List<String> instanceIds)
     throws PdcException {
   List<Value> pertinentValues = new ArrayList<Value>();
   ClassificationPlan pdc = aClassificationPlan();
   UsedAxis theAxis = pdc.getAxis(axisId);
   if (instanceIds.contains(theAxis.getInstanceId())) {
     List<Value> values = pdc.getValuesUsedInClassification(axisId);
     List<SearchCriteria> criteria = searchContext.getCriterias();
     if (criteria.isEmpty()) {
       return values;
     }
     for (Value aValue : values) {
       for (SearchCriteria criterion : criteria) {
         if (criterion.getAxisId() == Integer.valueOf(aValue.getAxisId())
             && criterion.getValue().equals(aValue.getFullPath())) {
           pertinentValues.add(aValue);
         }
       }
     }
   }
   return pertinentValues;
 }