Esempio n. 1
0
  @Override
  public void mergeWith(IdentifiableObject other) {
    super.mergeWith(other);

    if (other.getClass().isInstance(this)) {
      DataDictionary dataDictionary = (DataDictionary) other;

      description =
          dataDictionary.getDescription() == null ? description : dataDictionary.getDescription();
      region = dataDictionary.getRegion() == null ? region : dataDictionary.getRegion();

      removeAllDataElements();
      dataElements.addAll(dataDictionary.getDataElements());

      removeAllIndicators();
      indicators.addAll(dataDictionary.getIndicators());
    }
  }
  public void write(XMLWriter writer, ExportParams params) {
    Collection<DataDictionary> dataDictionaries =
        dataDictionaryService.getDataDictionaries(params.getDataDictionaries());

    if (dataDictionaries != null && dataDictionaries.size() > 0) {
      writer.openElement(COLLECTION_NAME);

      for (DataDictionary dictionary : dataDictionaries) {
        if (dictionary.getDataElements() != null) {
          for (Indicator indicator : dictionary.getIndicators()) {
            writer.openElement(ELEMENT_NAME);

            writer.writeElement(FIELD_DATADICTIONARY, String.valueOf(dictionary.getId()));
            writer.writeElement(FIELD_INDICATOR, String.valueOf(indicator.getId()));

            writer.closeElement();
          }
        }
      }

      writer.closeElement();
    }
  }