Пример #1
0
  private void addMetacardSubject(
      final XstreamPathValueTracker pathValueTracker, MetacardImpl metacard) {

    List<String> subjects = pathValueTracker.getAllValues(KEYWORD_PATH);
    subjects.addAll(pathValueTracker.getAllValues(TOPIC_CATEGORY_PATH));
    metacard.setAttribute(GmdMetacardType.GMD_SUBJECT, (Serializable) subjects);
  }
Пример #2
0
  private void addMetacardLocation(
      final XstreamPathValueTracker pathValueTracker, MetacardImpl metacard) {
    String westLon = pathValueTracker.getPathValue(BBOX_WEST_LON_PATH);
    String eastLon = pathValueTracker.getPathValue(BBOX_EAST_LON_PATH);
    String southLat = pathValueTracker.getPathValue(BBOX_SOUTH_LAT_PATH);
    String northLat = pathValueTracker.getPathValue(BBOX_NORTH_LAT_PATH);

    if (westLon != null && eastLon != null && southLat != null && northLat != null) {
      WKTWriter wktWriter = new WKTWriter();

      GeometryFactory factory = new GeometryFactory();
      try {
        Envelope envelope =
            new Envelope(
                Double.parseDouble(eastLon.trim()),
                Double.parseDouble(westLon.trim()),
                Double.parseDouble(southLat.trim()),
                Double.parseDouble(northLat.trim()));
        String wkt = wktWriter.write(factory.toGeometry(envelope));
        if (wkt != null) {
          metacard.setLocation(wkt);
        }
      } catch (NumberFormatException nfe) {
        LOGGER.info(
            "Unable to parse double from GMD metadata {}, {}, {}, {}",
            westLon,
            eastLon,
            southLat,
            northLat);
      }
    }
  }
Пример #3
0
 private void addMetacardCrs(
     final XstreamPathValueTracker pathValueTracker, MetacardImpl metacard) {
   StringBuilder crs = new StringBuilder();
   crs.append("urn:ogc:def:crs:");
   crs.append(StringUtils.defaultString(pathValueTracker.getPathValue(CRS_AUTHORITY_PATH)));
   crs.append(COLON);
   crs.append(StringUtils.defaultString(pathValueTracker.getPathValue(CRS_VERSION_PATH)));
   crs.append(COLON);
   crs.append(StringUtils.defaultString(pathValueTracker.getPathValue(CRS_CODE_PATH)));
   metacard.setAttribute(GmdMetacardType.GMD_CRS, crs.toString());
 }
Пример #4
0
 private void addMetacardFormat(
     final XstreamPathValueTracker pathValueTracker, MetacardImpl metacard) {
   String format = pathValueTracker.getPathValue(FORMAT_PATH);
   if (StringUtils.isNotEmpty((format))) {
     metacard.setAttribute(GmdMetacardType.GMD_FORMAT, format);
   }
 }
Пример #5
0
 private void addMetacardAbstract(
     final XstreamPathValueTracker pathValueTracker, MetacardImpl metacard) {
   String gmdAbstract = pathValueTracker.getPathValue(ABSTRACT_PATH);
   if (StringUtils.isNotEmpty(gmdAbstract)) {
     metacard.setDescription(gmdAbstract);
   }
 }
Пример #6
0
 private void addMetacardTitle(
     final XstreamPathValueTracker pathValueTracker, MetacardImpl metacard) {
   String title = pathValueTracker.getPathValue(TITLE_PATH);
   if (StringUtils.isNotEmpty(title)) {
     metacard.setTitle(title);
   }
 }
Пример #7
0
  private MetacardImpl toMetacard(final XstreamPathValueTracker pathValueTracker, final String id) {
    MetacardImpl metacard = new MetacardImpl(GMD_METACARD_TYPE);

    if (StringUtils.isNotEmpty(id)) {
      metacard.setAttribute(Metacard.ID, id);
    } else {
      metacard.setId(pathValueTracker.getPathValue(FILE_IDENTIFIER_PATH));
    }
    addMetacardDates(pathValueTracker, metacard);

    addMetacardType(pathValueTracker, metacard);

    addMetacardCrs(pathValueTracker, metacard);

    addMetacardTitle(pathValueTracker, metacard);

    addMetacardAbstract(pathValueTracker, metacard);

    addMetacardFormat(pathValueTracker, metacard);

    addMetacardResourceUri(pathValueTracker, metacard);

    addMetacardLocation(pathValueTracker, metacard);

    addMetacardSubject(pathValueTracker, metacard);

    setPointOfContact(pathValueTracker, metacard);

    return metacard;
  }
Пример #8
0
  private void addMetacardType(
      final XstreamPathValueTracker pathValueTracker, MetacardImpl metacard) {

    String type = pathValueTracker.getPathValue(CODE_LIST_VALUE_PATH);
    if (StringUtils.isNotEmpty(type)) {
      metacard.setContentTypeName(type);
    }
  }
Пример #9
0
  private void setPointOfContact(
      final XstreamPathValueTracker pathValueTracker, MetacardImpl metacard) {

    String pointOfContact = pathValueTracker.getPathValue(POINT_OF_CONTACT_PATH);
    if (StringUtils.isNotEmpty(pointOfContact)) {
      metacard.setPointOfContact(pointOfContact);
      metacard.setAttribute(GmdMetacardType.GMD_PUBLISHER, pointOfContact);
    }
  }
Пример #10
0
  private void addMetacardDates(
      final XstreamPathValueTracker pathValueTracker, MetacardImpl metacard) {

    String dateStr = pathValueTracker.getPathValue(DATE_STAMP_PATH);
    if (StringUtils.isNotEmpty(dateStr)) {
      Date date = CswUnmarshallHelper.convertToDate(dateStr);
      metacard.setModifiedDate(date);
      metacard.setCreatedDate(date);
    }
  }
Пример #11
0
 private void addMetacardResourceUri(
     final XstreamPathValueTracker pathValueTracker, MetacardImpl metacard) {
   String linkage = pathValueTracker.getPathValue(LINKAGE_URI_PATH);
   if (StringUtils.isNotEmpty(linkage)) {
     try {
       metacard.setResourceURI(new URI(linkage));
     } catch (URISyntaxException e) {
       LOGGER.info("Unable to read resource URI {}", linkage, e);
     }
   }
 }