コード例 #1
0
  private void writeAttributes(XMLStreamWriter xmlWriter, AttributeTable table) throws Exception {
    List<AttributeColumn> staticCols = new ArrayList<AttributeColumn>();
    List<AttributeColumn> dynamicCols = new ArrayList<AttributeColumn>();
    String attClass = table == attributeModel.getNodeTable() ? "node" : "edge";

    for (AttributeColumn col : table.getColumns()) {

      if (!col.getOrigin().equals(AttributeOrigin.PROPERTY)) {
        if (exportDynamic && col.getType().isDynamicType()) {
          dynamicCols.add(col);
        } else {
          staticCols.add(col);
        }
      } else if (exportDynamic
          && col.getType().isDynamicType()
          && col.getType() != AttributeType.TIME_INTERVAL
          && col.getOrigin().equals(AttributeOrigin.PROPERTY)
          && col.getIndex() == PropertiesColumn.EDGE_WEIGHT.getIndex()) {
        dynamicCols.add(col);
      }
    }

    if (!staticCols.isEmpty()) {
      writeAttributes(xmlWriter, staticCols.toArray(new AttributeColumn[0]), "static", attClass);
    }
    if (!dynamicCols.isEmpty()) {
      writeAttributes(xmlWriter, dynamicCols.toArray(new AttributeColumn[0]), "dynamic", attClass);
    }
  }
コード例 #2
0
  private void writeAttributes(
      XMLStreamWriter xmlWriter, AttributeColumn[] cols, String mode, String attClass)
      throws Exception {
    if (exportAttributes) {
      xmlWriter.writeStartElement(ATTRIBUTES);
      xmlWriter.writeAttribute(ATTRIBUTES_CLASS, attClass);
      xmlWriter.writeAttribute(ATTRIBUTES_MODE, mode);

      for (AttributeColumn col : cols) {
        if (!col.getOrigin().equals(AttributeOrigin.PROPERTY)
            || (exportDynamic
                && col.getOrigin().equals(AttributeOrigin.PROPERTY)
                && col.getIndex() == PropertiesColumn.EDGE_WEIGHT.getIndex())) {
          xmlWriter.writeStartElement(ATTRIBUTE);
          xmlWriter.writeAttribute(ATTRIBUTE_ID, col.getId());
          xmlWriter.writeAttribute(ATTRIBUTE_TITLE, col.getTitle());
          if (col.getType().equals(AttributeType.INT)) {
            xmlWriter.writeAttribute(ATTRIBUTE_TYPE, "integer");
          } else if (col.getType().isListType()) {
            if (col.getType().equals(AttributeType.LIST_INTEGER)) {
              xmlWriter.writeAttribute(ATTRIBUTE_TYPE, "listint");
            } else if (col.getType().equals(AttributeType.LIST_CHARACTER)) {
              xmlWriter.writeAttribute(ATTRIBUTE_TYPE, "listchar");
            } else {
              xmlWriter.writeAttribute(
                  ATTRIBUTE_TYPE, col.getType().getTypeString().toLowerCase().replace("_", ""));
            }
          } else if (col.getType().isDynamicType()) {
            AttributeType staticType = TypeConvertor.getStaticType(col.getType());
            if (staticType.equals(AttributeType.INT)) {
              xmlWriter.writeAttribute(ATTRIBUTE_TYPE, "integer");
            } else {
              xmlWriter.writeAttribute(ATTRIBUTE_TYPE, staticType.getTypeString().toLowerCase());
            }
          } else {
            xmlWriter.writeAttribute(ATTRIBUTE_TYPE, col.getType().getTypeString().toLowerCase());
          }
          if (col.getDefaultValue() != null) {
            xmlWriter.writeStartElement(ATTRIBUTE_DEFAULT);
            xmlWriter.writeCharacters(col.getDefaultValue().toString());
            xmlWriter.writeEndElement();
          }
          xmlWriter.writeEndElement();
        }
      }

      xmlWriter.writeEndElement();
    }
  }
コード例 #3
0
 private void writeAttValues(
     XMLStreamWriter xmlWriter, AttributeRow row, TimeInterval visibleInterval) throws Exception {
   xmlWriter.writeStartElement(ATTVALUES);
   for (AttributeValue val : row.getValues()) {
     AttributeColumn col = val.getColumn();
     if (!col.getOrigin().equals(AttributeOrigin.PROPERTY)
         || (exportDynamic
             && col.getOrigin().equals(AttributeOrigin.PROPERTY)
             && col.getIndex() == PropertiesColumn.EDGE_WEIGHT.getIndex())) {
       AttributeType type = col.getType();
       if (type.isDynamicType()) {
         DynamicType dynamicValue = (DynamicType) val.getValue();
         if (dynamicValue != null && visibleInterval != null && exportDynamic) {
           List<Interval<?>> intervals =
               dynamicValue.getIntervals(visibleInterval.getLow(), visibleInterval.getHigh());
           for (Interval<?> interval : intervals) {
             Object value = interval.getValue();
             if (value != null) {
               xmlWriter.writeStartElement(ATTVALUE);
               xmlWriter.writeAttribute(ATTVALUE_FOR, col.getId());
               xmlWriter.writeAttribute(ATTVALUE_VALUE, value.toString());
               if (!Double.isInfinite(interval.getLow())) {
                 String intervalLow = formatTime(interval.getLow());
                 xmlWriter.writeAttribute(
                     interval.isLowExcluded() ? START_OPEN : START, intervalLow);
               }
               if (!Double.isInfinite(interval.getHigh())) {
                 String intervalHigh = formatTime(interval.getHigh());
                 xmlWriter.writeAttribute(
                     interval.isHighExcluded() ? END_OPEN : END, intervalHigh);
               }
               xmlWriter.writeEndElement();
             }
           }
         } else if (dynamicValue != null) {
           TimeInterval interval = visibleInterval;
           if (interval == null) {
             interval = new TimeInterval();
           }
           Object value =
               DynamicUtilities.getDynamicValue(
                   dynamicValue, interval.getLow(), interval.getHigh());
           if (value != null) {
             xmlWriter.writeStartElement(ATTVALUE);
             xmlWriter.writeAttribute(ATTVALUE_FOR, val.getColumn().getId());
             xmlWriter.writeAttribute(ATTVALUE_VALUE, value.toString());
             xmlWriter.writeEndElement();
           }
         }
       } else {
         if (val.getValue() != null) {
           xmlWriter.writeStartElement(ATTVALUE);
           xmlWriter.writeAttribute(ATTVALUE_FOR, col.getId());
           xmlWriter.writeAttribute(ATTVALUE_VALUE, val.getValue().toString());
           xmlWriter.writeEndElement();
         }
       }
     }
   }
   xmlWriter.writeEndElement();
 }