コード例 #1
0
 public String toPropositionId(DataElementEntity dataElement) {
   return toPropositionId(dataElement.getKey());
 }
コード例 #2
0
 public String asValueCompString(DataElementEntity dataElement) {
   return asValueCompString(dataElement.getKey());
 }
コード例 #3
0
  @Override
  public List<PropositionDefinition> convert(FrequencyEntity entity) {
    if (entity.getAbstractedFrom() == null) {
      throw new IllegalArgumentException("entity cannot have a null abstractedFrom field");
    }
    List<PropositionDefinition> result = new ArrayList<>();
    String propId = this.conversionSupport.toPropositionId(entity);
    this.primaryPropId = propId;
    if (this.converterVisitor.addPropositionId(propId)) {
      ExtendedDataElement extendedProposition = entity.getExtendedProposition();
      HighLevelAbstractionDefinition p = new HighLevelAbstractionDefinition(propId);
      p.setDisplayName(entity.getDisplayName());
      p.setDescription(entity.getDescription());
      p.setGapFunction(new SimpleGapFunction(0, null));
      if (entity.getFrequencyType().getName().equals("at least")) {
        DataElementEntity abstractedFrom = extendedProposition.getDataElementEntity();
        abstractedFrom.accept(converterVisitor);
        result.addAll(converterVisitor.getPropositionDefinitions());
        TemporalExtendedPropositionDefinition[] tepds =
            new TemporalExtendedPropositionDefinition[entity.getCount()];
        for (int i = 0; i < entity.getCount(); i++) {
          TemporalExtendedPropositionDefinition tepd =
              ConversionUtil.buildExtendedPropositionDefinition(extendedProposition);
          tepds[i] = tepd;
          p.add(tepd);
        }
        if (tepds.length > 1) {
          for (int i = 0; i < tepds.length - 1; i++) {
            Relation rel =
                new Relation(
                    null,
                    null,
                    null,
                    null,
                    null,
                    null,
                    null,
                    null,
                    entity.getWithinAtLeast(),
                    unit(entity.getWithinAtLeastUnits()),
                    entity.getWithinAtMost(),
                    unit(entity.getWithinAtMostUnits()),
                    null,
                    null,
                    null,
                    null);
            p.setRelation(tepds[i], tepds[i + 1], rel);
          }
        } else {
          p.setRelation(tepds[0], tepds[0], new Relation());
        }
      } else if (entity.getFrequencyType().getName().equals("first")) {
        String wrapperPropId = entity.getKey() + "_SUB";
        SliceDefinition sp = new SliceDefinition(wrapperPropId);
        sp.setDisplayName(entity.getDisplayName());
        sp.setDescription(entity.getDescription());
        DataElementEntity abstractedFrom = extendedProposition.getDataElementEntity();
        abstractedFrom.accept(converterVisitor);
        result.addAll(converterVisitor.getPropositionDefinitions());
        sp.setMergedInterval(true);
        sp.setGapFunction(new SimpleGapFunction(0, null));
        TemporalExtendedPropositionDefinition tepd =
            ConversionUtil.buildExtendedPropositionDefinition(extendedProposition);
        sp.add(tepd);
        sp.setMinIndex(0);
        sp.setMaxIndex(entity.getCount());
        sp.setSourceId(sourceId(entity));

        TemporalExtendedPropositionDefinition tepds =
            new TemporalExtendedPropositionDefinition(wrapperPropId);
        p.add(tepds);
        p.setRelation(tepds, tepds, new Relation());
        result.add(sp);
      } else {
        throw new IllegalStateException(
            "invalid frequency type: " + entity.getFrequencyType().getName());
      }

      p.setSourceId(sourceId(entity));
      this.primary = p;
      result.add(p);
    }
    return result;
  }