/** * Prints attributes using dcat mappings * * @param r record * @param before <code>true</code> if more info will be printed after that section */ protected void printAttributesUserDcatMappings(IFeedRecord r, boolean before) { String schemaKey = ""; Map<String, IFeedAttribute> index = r.getData(IFeedRecord.STD_COLLECTION_INDEX); IFeedAttribute schemaKeyAttr = index.get("sys.schema.key"); if (schemaKeyAttr != null) { schemaKey = cleanValue(schemaKeyAttr + "", "", "", null); } DcatFields dcatFields = null; Set<String> keys = this.dcatSchemas.keySet(); schemaKey = schemaKey.replaceAll("\"", ""); for (String key : keys) { if (key.contains(schemaKey)) { dcatFields = this.dcatSchemas.get(key); break; } } if (dcatFields == null) { dcatFields = this.dcatSchemas.get("others"); } if (dcatFields == null) { return; } printTab(); for (DcatField dcatField : dcatFields) { before = lookUpFieldFromDcat(r, dcatField, before); } ResourceLinks links = r.getResourceLinks(); printLinks(links, false, before); }
/** * Looks up dcat mapping field for a give a record and writes response. * * @param r the record * @param dcatField the dcat field * @param before the indentation boolean cursor * @return the indentation boolean cursor */ private boolean lookUpFieldFromDcat(IFeedRecord r, DcatField dcatField, boolean before) { String delimiter = ","; String dl = dcatField.getDelimiter(); if (dl.length() > 0) { delimiter = dl; } String indexKey = dcatField.getIndex(); Map<String, IFeedAttribute> index = r.getData(IFeedRecord.STD_COLLECTION_INDEX); if (indexKey.length() > 0) { before = writeField(r, index, dcatField, delimiter, before); } else if (dcatField.getName().equalsIgnoreCase("identifier") && indexKey.length() == 0) { ResourceLinks links = r.getResourceLinks(); before = writeFieldValue( "\"" + getIdentifierUrl(links) + "\"", "identifier", delimiter, before, dcatField); } return before; }