コード例 #1
0
  private void convertFeatures(Map<String, Object> map, Base base) {
    for (Feature f : base.getType().getFeatures()) {
      if (stopFeatures.contains(f.getName())) {
        continue;
      }

      try {
        convertFeature(map, base, f);
      } catch (Exception e) {
        getMonitor()
            .warn(
                "Couldn't output {} to map. Type '{}' isn't supported.",
                f.getName(),
                f.getRange().getShortName(),
                e);
      }
    }
    map.put("type", base.getType().getShortName());
    if (map.get(FIELD_VALUE) == null || Strings.isNullOrEmpty(map.get(FIELD_VALUE).toString())) {
      map.put(FIELD_VALUE, base.getCoveredText());
    }
  }
コード例 #2
0
 private void convertFeature(Map<String, Object> map, Base base, Feature f) {
   if (f.getRange().isPrimitive()) {
     if ("geoJson".equals(f.getShortName())) {
       getMonitor().trace("Feature is GeoJSON - parsing to a database object");
       putGeoJson(map, base.getFeatureValueAsString(f));
     } else {
       getMonitor().trace("Converting primitive feature to an object");
       map.put(ConsumerUtils.toCamelCase(f.getShortName()), FeatureUtils.featureToObject(f, base));
     }
   } else if (f.getRange().isArray()
       && f.getRange().getComponentType() != null
       && f.getRange().getComponentType().isPrimitive()) {
     getMonitor().trace("Converting primitive feature to an array");
     map.put(ConsumerUtils.toCamelCase(f.getShortName()), FeatureUtils.featureToArray(f, base));
   } else {
     getMonitor()
         .trace("Feature is not a primitive type - will try to treat the feature as an entity");
     if (f.getRange().isArray()) {
       getMonitor().trace("Feature is an array - attempting converstion to an array of entities");
       FSArray fArr = (FSArray) base.getFeatureValue(f);
       if (fArr != null) {
         map.put(ConsumerUtils.toCamelCase(f.getShortName()), getEntityIds(fArr));
       }
     } else {
       getMonitor().trace("Feature is singular - attempting conversion to a single entity");
       FeatureStructure ent = base.getFeatureValue(f);
       if (ent == null) {
         // Ignore null entities
       } else if (ent instanceof Entity) {
         map.put(ConsumerUtils.toCamelCase(f.getShortName()), ((Entity) ent).getExternalId());
       } else {
         getMonitor().trace("Unable to persist feature {}", f.getShortName());
       }
     }
   }
 }