diff --git a/source/java/org/alfresco/repo/search/impl/solr/facet/facetsresponse/GenericBucket.java b/source/java/org/alfresco/repo/search/impl/solr/facet/facetsresponse/GenericBucket.java new file mode 100644 index 0000000000..bd9883eda8 --- /dev/null +++ b/source/java/org/alfresco/repo/search/impl/solr/facet/facetsresponse/GenericBucket.java @@ -0,0 +1,74 @@ +/*- + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2017 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.repo.search.impl.solr.facet.facetsresponse; + +import java.util.List; + +/** + * A Generic Bucket response covering range, interval, pivot etc. + */ +public class GenericBucket +{ + private final String label; + private final String filterQuery; + private final Object display; + private final List metrics; + private final List facets; + + public GenericBucket(String label, String filterQuery, Object display, List metrics, List facets) + { + this.label = label; + this.filterQuery = filterQuery; + this.display = display; + this.metrics = metrics; + this.facets = facets; + } + + public String getFilterQuery() + { + return filterQuery; + } + + public Object getDisplay() + { + return display; + } + + public String getLabel() + { + return label; + } + + public List getMetrics() + { + return metrics; + } + + public List getFacets() + { + return facets; + } +} diff --git a/source/java/org/alfresco/repo/search/impl/solr/facet/facetsresponse/GenericFacetResponse.java b/source/java/org/alfresco/repo/search/impl/solr/facet/facetsresponse/GenericFacetResponse.java new file mode 100644 index 0000000000..2b6617e2b1 --- /dev/null +++ b/source/java/org/alfresco/repo/search/impl/solr/facet/facetsresponse/GenericFacetResponse.java @@ -0,0 +1,62 @@ +/*- + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2017 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.repo.search.impl.solr.facet.facetsresponse; + +import java.util.List; + +/** + * A Generic facet response covering range, interval, pivot etc. + */ +public class GenericFacetResponse +{ + public static enum FACET_TYPE {range, interval, pivot}; + private final FACET_TYPE type; + private final String label; + private final List buckets; + + public GenericFacetResponse(FACET_TYPE type, String label, List buckets) + { + this.type = type; + this.label = label; + this.buckets = buckets; + } + + public String getLabel() + { + return label; + } + + public List getBuckets() + { + return buckets; + } + + public FACET_TYPE getType() + { + return type; + } + +} diff --git a/source/java/org/alfresco/repo/search/impl/solr/facet/facetsresponse/Metric.java b/source/java/org/alfresco/repo/search/impl/solr/facet/facetsresponse/Metric.java new file mode 100644 index 0000000000..dbe1ade1d5 --- /dev/null +++ b/source/java/org/alfresco/repo/search/impl/solr/facet/facetsresponse/Metric.java @@ -0,0 +1,39 @@ +/*- + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2017 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.repo.search.impl.solr.facet.facetsresponse; + +import java.util.Map; + +/** + * Metrics returned from Solr + */ +public interface Metric +{ + public static enum METRIC_TYPE {count}; + + METRIC_TYPE getType(); + Map getValue(); +} diff --git a/source/java/org/alfresco/repo/search/impl/solr/facet/facetsresponse/MetricCount.java b/source/java/org/alfresco/repo/search/impl/solr/facet/facetsresponse/MetricCount.java new file mode 100644 index 0000000000..9d18e5be66 --- /dev/null +++ b/source/java/org/alfresco/repo/search/impl/solr/facet/facetsresponse/MetricCount.java @@ -0,0 +1,54 @@ +/*- + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2017 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.repo.search.impl.solr.facet.facetsresponse; + +import java.util.HashMap; +import java.util.Map; + +/** + * A count metric + */ +public class MetricCount implements Metric +{ + private final Map value = new HashMap<>(1); + + public MetricCount(Integer count) + { + value.put("count", count); + } + + @Override + public METRIC_TYPE getType() + { + return METRIC_TYPE.count; + } + + @Override + public Map getValue() + { + return value; + } +}