001/*-
002 * #%L
003 * Smile CDR - CDR
004 * %%
005 * Copyright (C) 2016 - 2024 Smile CDR, Inc.
006 * %%
007 * All rights reserved.
008 * #L%
009 */
010package ca.cdr.api.model.json;
011
012import com.fasterxml.jackson.annotation.JsonProperty;
013
014import java.util.HashMap;
015import java.util.LinkedHashMap;
016import java.util.Map;
017
018public class MdmMetricsJson implements IModelJson {
019
020        @JsonProperty("resourceType")
021        private String myResourceType;
022
023        /**
024         * A mapping of MatchType -> LinkSource -> count.
025         * Eg:
026         * MATCH
027         *              AUTO    - 2
028         *              MANUAL  - 1
029         * NO_MATCH
030         *      AUTO    - 1
031         *      MANUAL  - 3
032         */
033        @JsonProperty("matchResult2linkSource2count")
034        private Map<String, Map<String, Long>> myMatchTypeToLinkToCountMap;
035
036        /**
037         * Buckets of score values to count.
038         * Scores can be any number from 0->1, as well as null.
039         * Buckets are brackets of fixed size (~0.01) and null.
040         */
041        @JsonProperty("scoreCounts")
042        private Map<String, Long> myScoreCounts;
043
044        /**
045         * The number of golden resources.
046         */
047        @JsonProperty("goldenResources")
048        private long myGoldenResourcesCount;
049
050        /**
051         * The number of source resources.
052         */
053        @JsonProperty("sourceResources")
054        private long mySourceResourcesCount;
055
056        /**
057         * The number of excluded resources.
058         * These are necessarily a subset of both
059         * GoldenResources and SourceResources
060         * (as each Blocked resource will still generate
061         * a GoldenResource)
062         */
063        @JsonProperty("excludedResources")
064        private long myExcludedResources;
065
066        public String getResourceType() {
067                return myResourceType;
068        }
069
070        public Map<String, Map<String, Long>> getMatchTypeToLinkToCountMap() {
071                if (myMatchTypeToLinkToCountMap == null) {
072                        myMatchTypeToLinkToCountMap = new HashMap<>();
073                }
074                return myMatchTypeToLinkToCountMap;
075        }
076
077        public void addMetric(String theMdmMatchResultEnum, String theLinkSourceEnum, long theCount) {
078                Map<String, Map<String, Long>> map = getMatchTypeToLinkToCountMap();
079
080                if (!map.containsKey(theMdmMatchResultEnum)) {
081                        map.put(theMdmMatchResultEnum, new HashMap<>());
082                }
083                Map<String, Long> lsToCountMap = map.get(theMdmMatchResultEnum);
084                lsToCountMap.put(theLinkSourceEnum, theCount);
085        }
086
087        public void setResourceType(String theResourceType) {
088                myResourceType = theResourceType;
089        }
090
091        public long getGoldenResourcesCount() {
092                return myGoldenResourcesCount;
093        }
094
095        public void setGoldenResourcesCount(long theGoldenResourcesCount) {
096                myGoldenResourcesCount = theGoldenResourcesCount;
097        }
098
099        public long getSourceResourcesCount() {
100                return mySourceResourcesCount;
101        }
102
103        public void setSourceResourcesCount(long theSourceResourcesCount) {
104                mySourceResourcesCount = theSourceResourcesCount;
105        }
106
107        public long getExcludedResources() {
108                return myExcludedResources;
109        }
110
111        public void setExcludedResources(long theExcludedResources) {
112                myExcludedResources = theExcludedResources;
113        }
114
115        public Map<String, Long> getScoreCounts() {
116                if (myScoreCounts == null) {
117                        myScoreCounts = new LinkedHashMap<>();
118                }
119                return myScoreCounts;
120        }
121
122        public void addScore(String theScore, Long theCount) {
123                getScoreCounts().put(theScore, theCount);
124        }
125}