+ private static void writeIdentityValuesDTOToJson(final JsonWriter writer, final IdentityValuesDTO valueDTO)
+ throws IOException {
+ StringBuilder result = new StringBuilder();
+ for (IdentityValue identityValue : valueDTO.getValuesWithNamespaces()) {
+ result.append('/');
+
+ writeModuleNameAndIdentifier(result, identityValue);
+ if (identityValue.getPredicates() != null && !identityValue.getPredicates().isEmpty()) {
+ for (Predicate predicate : identityValue.getPredicates()) {
+ IdentityValue identityValuePredicate = predicate.getName();
+ result.append('[');
+ if (identityValuePredicate == null) {
+ result.append('.');
+ } else {
+ writeModuleNameAndIdentifier(result, identityValuePredicate);
+ }
+ result.append("='");
+ result.append(predicate.getValue());
+ result.append("']");
+ }
+ }
+ }
+
+ writer.value(result.toString());
+ }
+
+ private static void writeModuleNameAndIdentifier(final StringBuilder result, final IdentityValue identityValue) {
+ String moduleName = ControllerContext.getInstance().findModuleNameByNamespace(
+ URI.create(identityValue.getNamespace()));
+ if (moduleName != null && !moduleName.isEmpty()) {
+ result.append(moduleName);
+ result.append(':');
+ }
+ result.append(identityValue.getValue());
+ }
+
+ private static void writeStringRepresentation(final JsonWriter writer, final SimpleNode<?> node,
+ final TypeDefinition<?> baseType, final Class<?> requiredType) throws IOException {
+ Object value = node.getValue();
+ LOG.debug("Value of {}:{} is not instance of {} but is {}", baseType.getQName().getNamespace(), baseType
+ .getQName().getLocalName(), requiredType.getClass(), node.getValue().getClass());
+ if (value == null) {
+ writer.value("");
+ } else {
+ writer.value(String.valueOf(value));
+ }
+ }
+
+ private void writeEmptyDataTypeToJson(final JsonWriter writer) throws IOException {