示例#1
0
  /**
   * Prints all records.
   *
   * @param records records to print
   * @param more <code>true</code> if more info will be printed after that section
   */
  @Override
  protected void printRecords(IFeedRecords records, boolean more) {
    int numberOfHits = records.getOpenSearchProperties().getNumberOfHits();
    int counter = 0;

    this.dcatSchemas =
        ApplicationContext.getInstance()
            .getConfiguration()
            .getCatalogConfiguration()
            .getDcatSchemas();
    LOGGER.info("Beginning processing " + numberOfHits + " DCAT records...");
    for (int i = 0; i < records.size(); i++) {
      IFeedRecord record = records.get(i);
      Envelope envelope = record.getEnvelope();
      printRecord(record, envelope, i < records.size() - 1);

      if ((++counter) % 1000 == 0) {
        LOGGER.info(
            "Processed "
                + counter
                + "/"
                + numberOfHits
                + " DCAT records ("
                + (100 * counter) / numberOfHits
                + "%)");
      }
    }
  }
示例#2
0
  @Override
  public void write(IFeedRecords records) {

    String sTitle = normalizeResource(messageBroker.retrieveMessage("catalog.json.dcat.title"));
    String sDescription =
        normalizeResource(messageBroker.retrieveMessage("catalog.json.dcat.description"));
    String sKeyword = normalizeResource(messageBroker.retrieveMessage("catalog.json.dcat.keyword"));
    String sModified =
        normalizeResource(messageBroker.retrieveMessage("catalog.json.dcat.modified"));
    String sPublisher =
        normalizeResource(messageBroker.retrieveMessage("catalog.json.dcat.publisher"));
    String sPerson =
        normalizeResource(messageBroker.retrieveMessage("catalog.json.dcat.contactPoint"));
    String sMbox = normalizeResource(messageBroker.retrieveMessage("catalog.json.dcat.mbox"));
    String sIdentifier =
        normalizeResource(messageBroker.retrieveMessage("catalog.json.dcat.identifier"));
    String sAccessLevel =
        normalizeResource(messageBroker.retrieveMessage("catalog.json.dcat.accessLevel"));
    String sAccessLevelComment =
        normalizeResource(messageBroker.retrieveMessage("catalog.json.dcat.accessLevelComment"));
    String sBureauCode =
        normalizeResource(messageBroker.retrieveMessage("catalog.json.dcat.bureauCode"));
    String sProgramCode =
        normalizeResource(messageBroker.retrieveMessage("catalog.json.dcat.programCode"));
    String sDataDictionary =
        normalizeResource(messageBroker.retrieveMessage("catalog.json.dcat.dataDictionary"));
    String sAccessUrl =
        normalizeResource(messageBroker.retrieveMessage("catalog.json.dcat.accessURL"));
    String sWebService =
        normalizeResource(messageBroker.retrieveMessage("catalog.json.dcat.webService"));
    String sFormat = normalizeResource(messageBroker.retrieveMessage("catalog.json.dcat.format"));
    String sLicense = normalizeResource(messageBroker.retrieveMessage("catalog.json.dcat.license"));
    String sSpatial = normalizeResource(messageBroker.retrieveMessage("catalog.json.dcat.spatial"));
    String sTemporal =
        normalizeResource(messageBroker.retrieveMessage("catalog.json.dcat.temporal"));

    defaultValues.put("title", sTitle);
    defaultValues.put("description", sDescription);

    defaultValues.put("keyword", sKeyword);
    defaultValues.put("modified", sModified);

    defaultValues.put("publisher", sPublisher);
    defaultValues.put("contactPoint", sPerson);
    defaultValues.put("mbox", sMbox);
    defaultValues.put("identifier", "");
    defaultValues.put("accessLevel", sAccessLevel);
    defaultValues.put("accessLevelComment", sAccessLevelComment);

    defaultValues.put("bureauCode", sBureauCode);
    defaultValues.put("programCode", sProgramCode);

    defaultValues.put("dataDictionary", sDataDictionary);
    defaultValues.put("accessURL", sAccessUrl);
    defaultValues.put("webService", sWebService);
    defaultValues.put("format", sFormat);
    defaultValues.put("spatial", sSpatial);
    defaultValues.put("temporal", "");

    println("[");
    levelUp();

    println("{");
    levelUp();

    printArg("title", sTitle, true);
    printArg("description", sDescription, true);
    printArg2("keyword", sKeyword, true);
    if (sModified.length() > 0) {
      printArg("modified", sModified, true);
    } else {
      printArg("modified", DF.format(new Date()), true);
    }
    printArg("publisher", sPublisher, true);
    printArg("contactPoint", sPerson, true);
    printArg("mbox", sMbox, true);
    printArg("identifier", sIdentifier, true);
    printArg("accessLevel", sAccessLevel, true);
    printArg("accessLevelComment", sAccessLevelComment, true);
    printArg2("bureauCode", sBureauCode, true);
    printArg2("programCode", sProgramCode, true);
    if (sDataDictionary.length() > 0) {
      printArg("dataDictionary", sDataDictionary, true);
    }

    if (sAccessUrl.length() > 0) {
      printLinkArg("accessURL", sAccessUrl, true);
    } else if (query != null) {
      printLinkArg("accessURL", query.getRssProviderUrl(), true);
    } else {
      printLinkArg("accessURL", "", true);
    }

    if (sWebService.length() > 0) {
      printLinkArg("webService", sWebService, true);
    } else if (query != null) {
      printLinkArg("webService", query.getRssSourceUrl(), true);
    } else {
      printArg("webService", "", true);
    }

    printArg("format", "application/json", true);
    printArg("license", sLicense, true);
    printArg("spatial", sSpatial, true);
    printArg("temporal", sTemporal, false);

    levelDown();
    println(records != null && records.size() > 0 ? "}," : "}");
    if (records != null) {
      printRecords(records, true);
    }

    levelDown();
    println("]");
  }