class OrchestrationRequests {

    public List<org.onap.so.serviceinstancebeans.RequestProcessingData> mapRequestProcessingData(
            List<org.onap.so.db.request.beans.RequestProcessingData> processingData) {
        List<org.onap.so.serviceinstancebeans.RequestProcessingData> addedRequestProcessingData = new ArrayList<>();
        org.onap.so.serviceinstancebeans.RequestProcessingData finalProcessingData =
                new org.onap.so.serviceinstancebeans.RequestProcessingData();
        String currentGroupingId = null;
        HashMap<String, String> tempMap = new HashMap<>();
        List<HashMap<String, String>> tempList = new ArrayList<>();
        for (RequestProcessingData data : processingData) {
            String groupingId = data.getGroupingId();
            String tag = data.getTag();
            if (currentGroupingId == null || !currentGroupingId.equals(groupingId)) {
                if (!tempMap.isEmpty()) {
                    tempList.add(tempMap);
                    finalProcessingData.setDataPairs(tempList);
                    addedRequestProcessingData.add(finalProcessingData);
                }
                finalProcessingData = new org.onap.so.serviceinstancebeans.RequestProcessingData();
                if (groupingId != null) {
                    finalProcessingData.setGroupingId(groupingId);
                }
                if (tag != null) {
                    finalProcessingData.setTag(tag);
                }
                currentGroupingId = groupingId;
                tempMap = new HashMap<>();
                tempList = new ArrayList<>();
                if (data.getName() != null && data.getValue() != null) {
                    tempMap.put(data.getName(), data.getValue());
                }
            } else {
                if (data.getName() != null && data.getValue() != null) {
                    tempMap.put(data.getName(), data.getValue());
                }
            }
        }
        if (tempMap.size() > 0) {
            tempList.add(tempMap);
            finalProcessingData.setDataPairs(tempList);
        }
        addedRequestProcessingData.add(finalProcessingData);
        return addedRequestProcessingData;
    }

}