java/view-templates/src/main/java/io/opensaber/views/ViewTransformer.java
/**
     * transforms a given JsonNode to representation of view templates
     * view template indicates any new field or mask fields for transformation
     * 
     * @param viewTemplate
     * @param node
     * @return
     */
transforms a given JsonNode to representation of view templates
view template indicates any new field or mask fields for transformation

@param viewTemplate
@param node
@return
transforms a given JsonNode to representation of view templates view template indicates any new field or mask fields for transformation @param viewTemplate @param node @return
public JsonNode transform(ViewTemplate viewTemplate, JsonNode node) throws Exception {
		ObjectNode result = JsonNodeFactory.instance.objectNode();
		Iterator<Map.Entry<String, JsonNode>> fields = node.fields();
		while (fields.hasNext()) {
			String subjectType = fields.next().getKey();
			JsonNode nodeAttrs = node.get(subjectType);
			JsonNode resultNode = JsonNodeFactory.instance.objectNode();
			if (nodeAttrs.isArray()) {
				ArrayNode resultArray = JsonNodeFactory.instance.arrayNode();
				for (int i = 0; i < nodeAttrs.size(); i++) {
					JsonNode tNode = tranformNode(viewTemplate, nodeAttrs.get(i));
					resultArray.add(tNode);
				}
				resultNode = resultArray;
			} else if (nodeAttrs.isObject()) {
				resultNode = tranformNode(viewTemplate, nodeAttrs);
			} else {
				throw new IllegalArgumentException("Not a valid node for transformation, must be a object node or array node");
			}
			result.set(subjectType, resultNode);
		}
		return result;
	}
public JsonNode transform ( ViewTemplate viewTemplate , JsonNode node ) throws Exception { ObjectNode result = JsonNodeFactory . instance . objectNode ( ) ; Iterator < Map . Entry < String , JsonNode > > fields = node . fields ( ) ; while ( fields . hasNext ( ) ) { String subjectType = fields . next ( ) . getKey ( ) ; JsonNode nodeAttrs = node . get ( subjectType ) ; JsonNode resultNode = JsonNodeFactory . instance . objectNode ( ) ; if ( nodeAttrs . isArray ( ) ) { ArrayNode resultArray = JsonNodeFactory . instance . arrayNode ( ) ; for ( int i = 0 ; i < nodeAttrs . size ( ) ; i ++ ) { JsonNode tNode = tranformNode ( viewTemplate , nodeAttrs . get ( i ) ) ; resultArray . add ( tNode ) ; } resultNode = resultArray ; } else if ( nodeAttrs . isObject ( ) ) { resultNode = tranformNode ( viewTemplate , nodeAttrs ) ; } else { throw new IllegalArgumentException ( "Not a valid node for transformation, must be a object node or array node" ) ; } result . set ( subjectType , resultNode ) ; } return result ; }
transforms a given JsonNode to representation of view templates
 view template indicates any new field or mask fields for transformation
transforms a given JsonNode to representation of view templates view template indicates any new field or mask fields for transformation
// loops for all entityTypes