private boolean isReadyToPut(FMDProperty objectProperty) { return (objectProperty.getType() != null && ((objectProperty.getType().equals(STRING_TYPE) || objectProperty.getType().equals(NUMBER_TYPE)))) || (objectProperty.getPatternProperties() != null && objectProperty.getPatternProperties().equals(STRING_TYPE)); }
private Object getReturnedValueFromObject(FMDProperty fmdProperty, Object value, String titleBean) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { Object returnedValue = null; boolean isMap = fmdProperty.getPatternProperties() != null; if (isMap) { Object first = invokeMethodByReflection(titleBean, value, false); returnedValue = (first != null) ? invokeMethodByReflection(titleBean, first, true) : first; } else { returnedValue = invokeMethodByReflection(titleBean, value, isMap); } return returnedValue; }
private Object fillRecursive2(Iterator<Map.Entry<String, JsonNode>> fields, Object returnedValue) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { Map<String, Object> tempMap = new TreeMap<String, Object>(); ListIterator<Map.Entry<String, JsonNode>> listBack = Lists.newArrayList(fields).listIterator(); FMDProperty resultObj = fillObjectProperty(listBack); String type = resultObj.getType(); if (type != null) { /** STRING OR NUMBER* */ if (type.equals(STRING_TYPE) || type.equals(NUMBER_TYPE)) { Object valueStringType = invokeMethodByReflection(resultObj.getTitleBean(), returnedValue, false); if (valueStringType != null && !valueStringType.toString().equals("")) { tempMap.put( resultObj.getOrder(), new FMDescriptor( resultObj.getTitleBean(), resultObj.getTitleToVisualize(), resultObj.getDescription(), valueStringType)); return tempMap; } } /** OBJECT * */ else if (type.equals(OBJECT_TYPE)) { // 1) PROPERTIES if (resultObj.getProperties() != null) { ArrayList<Map.Entry<String, JsonNode>> itProperties = (ArrayList<Map.Entry<String, JsonNode>>) resultObj.getProperties(); handleProperties(tempMap, itProperties, returnedValue); } // 2) PATTERN PROPERTIES else if (resultObj.getProperties() == null && resultObj.getPatternProperties() != null) { Object valueObjPatternType = invokeMethodByReflection(resultObj.getTitleBean(), returnedValue, true); if (valueObjPatternType != null) { if (resultObj.getPatternProperties().equals(STRING_TYPE)) { String orderObj = getOrderFromEntity(resultObj.getOrder()); tempMap.put( orderObj, new FMDescriptor( resultObj.getTitleBean(), resultObj.getTitleToVisualize(), resultObj.getDescription(), valueObjPatternType)); } else { // TODO(FREEZED): there is not a type different from string System.out.println("here!"); } } } // 3) REF PROPERTY else if (resultObj.getProperties() == null && resultObj.getPatternProperties() == null && resultObj.getReference() != null) { handleReferences(resultObj.getReference(), resultObj, tempMap, returnedValue, false); return tempMap; } } /** ARRAY* */ else if (type.equals(ARRAY_TYPE)) { ArrayList<Map<String, Object>> result = new ArrayList<Map<String, Object>>(); ArrayList<Object> values = (ArrayList<Object>) returnedValue; JsonNode items = ((ObjectNode) resultObj.getItems()).deepCopy(); if (items.get(TYPE_FIELD) != null) { if (items.get(TYPE_FIELD).asText().equals(STRING_TYPE)) { String orderGlobal = getOrderFromEntity(resultObj.getOrder()); for (int arrCounter = 0; arrCounter < values.size(); arrCounter++) { Map<String, Object> tmp = new TreeMap<String, Object>(); String order = getOrderFromEntity(resultObj.getOrder()); tmp.put(order, values.get(arrCounter)); result.add(tmp); } tempMap.put(orderGlobal, result); } } else if (items.get(REF_FIELD) != null) { String orderGlobal = getOrderFromEntity(resultObj.getOrder()); String ref = items.get(REF_FIELD).asText(); String[] refSplitted = ref.substring(2).split("/"); // OJCODE case if (refSplitted[refSplitted.length - 1].equals(OJCODE_TYPE)) { tempMap.put( orderGlobal, new FMDescriptor( refSplitted[refSplitted.length - 1], resultObj.getTitleToVisualize(), resultObj.getDescription(), fillOjCode((ArrayList<OjCode>) returnedValue))); } else { handleReferences(items.get(REF_FIELD).asText(), null, tempMap, returnedValue, true); return tempMap; } } } } else { if (resultObj.getReference() != null) { handleReferences(resultObj.getReference(), resultObj, tempMap, returnedValue, false); } } return tempMap; }