All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.bdware.doip.cluster.util.DoipArgUtil.backup Maven / Gradle / Ivy

There is a newer version: 1.5.4
Show newest version
package org.bdware.doip.cluster.util;

import com.google.gson.JsonObject;
import org.bdware.doip.codec.digitalObject.DigitalObject;
import org.bdware.doip.codec.metadata.SearchParameter;
import org.bdware.doip.codec.operations.BasicOperations;

// 根据请求参数,组装RouteInfo的参数Arg
public class DoipArgUtil {
    public static JsonObject composeRouteInfoArg(BasicOperations operation, String identifier, SearchParameter sp, String element, boolean includeElementData, DigitalObject digitalObject) {
        JsonObject composedRes = new JsonObject();
        JsonObject headerProperties = new JsonObject();
        headerProperties.addProperty("identifier", identifier);
        switch (operation) {
            case Hello:
            case Delete:
            case ListOps:
                break;
            case Create:
            case Update:
            //    composedRes.addProperty("body", digitalObject.toString());
                break;
            case Search:
                JsonObject searchAttributes = new JsonObject();
                searchAttributes.addProperty("query", sp.query);
                searchAttributes.addProperty("pageNum", sp.pageNum);
                searchAttributes.addProperty("pageSize", sp.pageSize);
                searchAttributes.addProperty("type", sp.type);
                headerProperties.add("attributes", searchAttributes);
                break;
            case Retrieve:
                JsonObject retrieveAttributes = new JsonObject();
                if(element != null) retrieveAttributes.addProperty("element", element);
                if(includeElementData) retrieveAttributes.addProperty("includeElementData", "true");
                if(!retrieveAttributes.equals(new JsonObject())) headerProperties.add("attributes", retrieveAttributes);
                break;
        }

        composedRes.add("header", headerProperties);
        return composedRes;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy