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

com.netgrif.application.engine.elastic.web.requestbodies.CaseSearchRequest Maven / Gradle / Ivy

package com.netgrif.application.engine.elastic.web.requestbodies;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Builder
@NoArgsConstructor
@AllArgsConstructor
public class CaseSearchRequest implements Serializable {

    private static final long serialVersionUID = 5468800723081186371L;

    @JsonFormat(with = JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY)
    public List process;

    @Deprecated(since = "6.3.0")
    @JsonFormat(with = JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY)
    public List processIdentifier;

    @JsonFormat(with = JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY)
    public List author;

    public Map data;

    public String fullText;

    public String uriNodeId;

    @JsonFormat(with = JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY)
    public List transition;

    @JsonFormat(with = JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY)
    public List role;

    public String query;

    @JsonFormat(with = JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY)
    public List stringId;

    @JsonFormat(with = JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY)
    public List group;

    public Map tags;

    public CaseSearchRequest(Map request) {
        if (request.containsKey("process") && request.get("process") instanceof List) {
            List processIdentifiers = (List) request.get("process");
            this.process = processIdentifiers.stream().map(PetriNet::new).collect(Collectors.toList());
        }
        if (request.containsKey("processIdentifier") && request.get("processIdentifier") instanceof List) {
            this.processIdentifier = (List) request.get("processIdentifier");
        }
        if (request.containsKey("author") && request.get("author") instanceof List) {
            List> authors = (List>) request.get("author");
            this.author = authors.stream().map(map ->  {
                Author authorRequest = new Author();
                if (map.containsKey("id"))
                    authorRequest.id = map.get("id");
                if (map.containsKey("name"))
                    authorRequest.name = map.get("name");
                if (map.containsKey("email"))
                    authorRequest.email = map.get("email");
                return authorRequest;
            }).collect(Collectors.toList());
        }
        if (request.containsKey("data") && request.get("data") instanceof Map) {
            this.data = (Map) request.get("data");
        }
        if (request.containsKey("fullText") && request.get("fullText") instanceof String) {
            this.fullText = (String) request.get("fullText");
        }
        if (request.containsKey("transition") && request.get("transition") instanceof List) {
            this.transition = (List) request.get("transition");
        }
        if (request.containsKey("role") && request.get("role") instanceof List) {
            this.role = (List) request.get("role");
        }
        if (request.containsKey("query") && request.get("query") instanceof String) {
            this.query = (String) request.get("query");
        }
        if (request.containsKey("stringId") && request.get("stringId") instanceof List) {
            this.stringId = (List) request.get("stringId");
        }
        if (request.containsKey("group") && request.get("group") instanceof List) {
            this.group = (List) request.get("group");
        }
    }

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class PetriNet implements Serializable {

        private static final long serialVersionUID = 4251438418424494690L;

        public String identifier;

        public String processId;

        public PetriNet(String identifier) {
            this.identifier = identifier;
        }
    }

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class Author implements Serializable {

        private static final long serialVersionUID = -4013905721499512553L;

        public String id;

        public String name;

        public String email;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy