@SuppressWarnings("unchecked") protected void addValueToMap(PredicateObjectMap pom, GenericRecord subject, Object object, String shortHandPredicateURI) { String mapPredicateName = pom.getPredicate().getId().replaceAll("[^\\w]", "_"); if(object instanceof String) { Map<String, String> values; if(subject.get(mapPredicateName)== null) { subject.put(mapPredicateName, new ConcurrentHashMap<String, String>()); } values = (Map<String, String>)subject.get(mapPredicateName); values.put(shortHandPredicateURI, (String)object); } else if(object instanceof GenericRecord) { Map<String, GenericRecord> values; if(subject.get(mapPredicateName)== null) { subject.put(mapPredicateName, new ConcurrentHashMap<String, GenericRecord>()); } values = (Map<String, GenericRecord>)subject.get(mapPredicateName); values.put(shortHandPredicateURI, (GenericRecord)object); } } @SuppressWarnings("unchecked")
Schema schema = subject.getSchema(); Field field = schema.getField(shortHandPredicateURI); Field mapField = schema.getField(pom.getPredicate().getId().replaceAll("[^\\w]", "_")); if (subject.get(shortHandPredicateURI) != null || predicateUri.contains(Uris.RDF_TYPE_URI)) {
LOG.error("Unable to generate plan for link " + link.getSourceMap().getId() + " " + link.getPredicateObjectMapLink().getPredicate().getId() + " " + link.getTargetMap().getId(), e);
fieldAssembler = fieldAssembler.name(pom.getPredicate().getId().replaceAll("[^\\w]", "_")).type().unionOf().map().values().unionOf().map().values().stringType().and().stringType().and().nullType().endUnion().and().nullType().endUnion().noDefault(); fieldAssembler = fieldAssembler.name(pom.getPredicate().getId().replaceAll("[^\\w]", "_")).type().unionOf().map().values().unionOf().map().values(targetSchema).and().type(targetSchema).and().nullType().endUnion().and().nullType().endUnion().noDefault();