http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/cfc12dad/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/builders/CXSEventBuilders.java ---------------------------------------------------------------------- diff --git a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/builders/CXSEventBuilders.java b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/builders/CXSEventBuilders.java deleted file mode 100644 index 8c616d4..0000000 --- a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/builders/CXSEventBuilders.java +++ /dev/null @@ -1,465 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.unomi.graphql.builders; - -import graphql.annotations.processor.GraphQLAnnotationsComponent; -import graphql.annotations.processor.ProcessingElementsContainer; -import graphql.schema.*; -import org.apache.unomi.graphql.propertytypes.*; -import org.apache.unomi.graphql.types.input.CXSEventInput; -import org.apache.unomi.graphql.types.input.CXSEventOccurrenceFilterInput; -import org.apache.unomi.graphql.types.output.CXSEvent; -import org.apache.unomi.graphql.types.output.CXSEventProperties; -import org.apache.unomi.graphql.types.output.CXSEventType; -import org.apache.unomi.graphql.types.output.PageInfo; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import static graphql.Scalars.*; -import static graphql.schema.GraphQLFieldDefinition.newFieldDefinition; -import static graphql.schema.GraphQLInputObjectField.newInputObjectField; -import static graphql.schema.GraphQLInputObjectType.newInputObject; -import static graphql.schema.GraphQLObjectType.newObject; - -public class CXSEventBuilders implements CXSBuilder { - - private GraphQLAnnotationsComponent annotationsComponent; - private ProcessingElementsContainer container; - private Map<String, CXSEventType> eventTypes; - private Map<String,GraphQLType> typeRegistry; - - public CXSEventBuilders(GraphQLAnnotationsComponent annotationsComponent, - ProcessingElementsContainer container, - Map<String, CXSEventType> eventTypes) { - this.annotationsComponent = annotationsComponent; - this.container = container; - this.eventTypes = eventTypes; - this.typeRegistry = container.getTypeRegistry(); - } - - @Override - public void updateTypes() { - Map<String,GraphQLType> typeRegistry = container.getTypeRegistry(); - typeRegistry.put("CXS_EventInput", buildCXSEventInputType()); - typeRegistry.put("CXS_EventOccurrenceFilterInput", annotationsComponent.getInputTypeProcessor().getInputTypeOrRef(CXSEventOccurrenceFilterInput.class, container)); - typeRegistry.put("CXS_EventPropertiesFilterInput", buildCXSEventPropertiesFilterInput()); - typeRegistry.put("CXS_EventFilterInput", buildCXSEventFilterInputType()); - typeRegistry.put("CXS_EventProperties", buildCXSEventPropertiesOutputType()); - typeRegistry.put("CXS_Event", buildCXSEventOutputType()); - typeRegistry.put("CXS_EventEdge", buildCXSEventEdgeOutputType()); - typeRegistry.put("CXS_EventConnection", buildCXSEventConnectionOutputType()); - } - - private GraphQLOutputType buildCXSEventEdgeOutputType() { - return newObject() - .name("CXS_EventEdge") - .description("The Relay edge type for the CXS_Event output type") - .field(newFieldDefinition() - .name("node") - .type((GraphQLOutputType) typeRegistry.get("CXS_Event")) - ) - .field(newFieldDefinition() - .name("cursor") - .type(GraphQLString) - ) - .build(); - } - - private GraphQLOutputType buildCXSEventConnectionOutputType() { - return newObject() - .name("CXS_EventConnection") - .description("The Relay connection type for the CXS_Event output type") - .field(newFieldDefinition() - .name("edges") - .type(new GraphQLList(typeRegistry.get("CXS_EventEdge"))) - ) - .field(newFieldDefinition() - .name("pageInfo") - .type(new GraphQLList(typeRegistry.get(PageInfo.class.getName()))) - ) - .build(); - } - - private GraphQLInputType buildCXSEventPropertiesFilterInput() { - GraphQLInputObjectType.Builder cxsEventPropertiesFilterInput = newInputObject() - .name("CXS_EventPropertiesFilterInput") - .description("Filter conditions for each event types and built-in properties"); - - generateEventPropertiesFilters(cxsEventPropertiesFilterInput); - generateEventTypesFilters(cxsEventPropertiesFilterInput); - - return cxsEventPropertiesFilterInput.build(); - } - - - private void generateEventPropertiesFilters(GraphQLInputObjectType.Builder cxsEventPropertiesFilterInput) { - addIdentityFilters("id", cxsEventPropertiesFilterInput); - addIdentityFilters("sourceId", cxsEventPropertiesFilterInput); - addIdentityFilters("clientId", cxsEventPropertiesFilterInput); - addIdentityFilters("profileId", cxsEventPropertiesFilterInput); - addDistanceFilters("location", cxsEventPropertiesFilterInput); - addDateFilters("timestamp", cxsEventPropertiesFilterInput); - } - - private void generateEventTypesFilters(GraphQLInputObjectType.Builder cxsEventPropertiesFilterInput) { - for (Map.Entry<String,CXSEventType> eventTypeEntry : eventTypes.entrySet()) { - addSetFilters(eventTypeEntry.getKey(), eventTypeEntry.getValue().getProperties(), cxsEventPropertiesFilterInput); - } - } - - private void addSetFilters(String eventTypeName, List<CXSPropertyType> properties, GraphQLInputObjectType.Builder inputTypeBuilder) { - GraphQLInputObjectType.Builder eventTypeFilterInput = newInputObject() - .name(eventTypeName + "FilterInput") - .description("Auto-generated filter input type for event type " + eventTypeName); - - for (CXSPropertyType cxsPropertyType : properties) { - if (cxsPropertyType instanceof CXSIdentifierPropertyType) { - addIdentityFilters(cxsPropertyType.getName(), eventTypeFilterInput); - } else if (cxsPropertyType instanceof CXSStringPropertyType) { - addStringFilters(cxsPropertyType.getName(), eventTypeFilterInput); - } else if (cxsPropertyType instanceof CXSBooleanPropertyType) { - addBooleanFilters(cxsPropertyType.getName(), eventTypeFilterInput); - } else if (cxsPropertyType instanceof CXSIntPropertyType) { - addIntegerFilters(cxsPropertyType.getName(), eventTypeFilterInput); - } else if (cxsPropertyType instanceof CXSFloatPropertyType) { - addFloatFilters(cxsPropertyType.getName(), eventTypeFilterInput); - } else if (cxsPropertyType instanceof CXSGeoPointPropertyType) { - addDistanceFilters(cxsPropertyType.getName(), eventTypeFilterInput); - } else if (cxsPropertyType instanceof CXSDatePropertyType) { - addDateFilters(cxsPropertyType.getName(), eventTypeFilterInput); - } else if (cxsPropertyType instanceof CXSSetPropertyType) { - addSetFilters(cxsPropertyType.getName(), ((CXSSetPropertyType) cxsPropertyType).getProperties(), eventTypeFilterInput); - } - } - - typeRegistry.put(eventTypeName + "FilterInput", eventTypeFilterInput.build()); - - inputTypeBuilder.field(newInputObjectField() - .name(eventTypeName) - .type((GraphQLInputType) typeRegistry.get(eventTypeName + "FilterInput")) - ); - - } - - private void addIdentityFilters(String propertyName, GraphQLInputObjectType.Builder inputTypeBuilder) { - inputTypeBuilder.field(newInputObjectField() - .name(propertyName + "_equals") - .type(GraphQLString) - ); - } - - private void addStringFilters(String propertyName, GraphQLInputObjectType.Builder inputTypeBuilder) { - inputTypeBuilder.field(newInputObjectField() - .name(propertyName + "_equals") - .type(GraphQLString) - ); - inputTypeBuilder.field(newInputObjectField() - .name(propertyName + "_regexp") - .type(GraphQLString) - ); - inputTypeBuilder.field(newInputObjectField() - .name(propertyName + "_startsWith") - .type(GraphQLString) - ); - inputTypeBuilder.field(newInputObjectField() - .name(propertyName + "_contains") - .type(new GraphQLList(GraphQLString)) - ); - } - - private void addBooleanFilters(String propertyName, GraphQLInputObjectType.Builder inputTypeBuilder) { - inputTypeBuilder.field(newInputObjectField() - .name(propertyName + "_equals") - .type(GraphQLBoolean) - ); - } - - private void addIntegerFilters(String propertyName, GraphQLInputObjectType.Builder inputTypeBuilder) { - inputTypeBuilder.field(newInputObjectField() - .name(propertyName + "_equals") - .type(GraphQLInt) - ); - inputTypeBuilder.field(newInputObjectField() - .name(propertyName + "_gt") - .type(GraphQLInt) - ); - inputTypeBuilder.field(newInputObjectField() - .name(propertyName + "_gte") - .type(GraphQLInt) - ); - inputTypeBuilder.field(newInputObjectField() - .name(propertyName + "_lt") - .type(GraphQLInt) - ); - inputTypeBuilder.field(newInputObjectField() - .name(propertyName + "_lte") - .type(GraphQLInt) - ); - } - - private void addFloatFilters(String propertyName, GraphQLInputObjectType.Builder inputTypeBuilder) { - inputTypeBuilder.field(newInputObjectField() - .name(propertyName + "_equals") - .type(GraphQLFloat) - ); - inputTypeBuilder.field(newInputObjectField() - .name(propertyName + "_gt") - .type(GraphQLFloat) - ); - inputTypeBuilder.field(newInputObjectField() - .name(propertyName + "_gte") - .type(GraphQLFloat) - ); - inputTypeBuilder.field(newInputObjectField() - .name(propertyName + "_lt") - .type(GraphQLFloat) - ); - inputTypeBuilder.field(newInputObjectField() - .name(propertyName + "_lte") - .type(GraphQLFloat) - ); - } - - private void addDistanceFilters(String propertyName, GraphQLInputObjectType.Builder inputTypeBuilder) { - inputTypeBuilder.field(newInputObjectField() - .name(propertyName + "_distance") - .type((GraphQLInputType) typeRegistry.get("CXS_GeoDistanceInput")) - ); - } - - private void addDateFilters(String propertyName, GraphQLInputObjectType.Builder inputTypeBuilder) { - inputTypeBuilder.field(newInputObjectField() - .name(propertyName + "_between") - .type((GraphQLInputType) typeRegistry.get("CXS_DateFilterInput")) - ); - } - - private GraphQLInputType buildCXSEventFilterInputType() { - GraphQLInputObjectType.Builder cxsEventFilterInputType = newInputObject() - .name("CXS_EventFilterInput") - .description("Filter conditions for each event types and built-in properties") - .field(newInputObjectField() - .name("and") - .type(new GraphQLList(new GraphQLTypeReference("CXS_EventFilterInput"))) - ) - .field(newInputObjectField() - .name("or") - .type(new GraphQLList(new GraphQLTypeReference("CXS_EventFilterInput"))) - ) - .field(newInputObjectField() - .name("properties") - .type((GraphQLInputType) typeRegistry.get("CXS_EventPropertiesFilterInput")) - ) - .field(newInputObjectField() - .name("properties_or") - .type((GraphQLInputType) typeRegistry.get("CXS_EventPropertiesFilterInput")) - ) - .field(newInputObjectField() - .name("eventOccurrence") - .type((GraphQLInputType) typeRegistry.get("CXS_EventOccurrenceFilterInput")) - ); - return cxsEventFilterInputType.build(); - } - - private GraphQLInputType buildCXSEventInputType() { - GraphQLInputObjectType.Builder cxsEventInputType = CXSBuildersUtils.getInputBuilderFromAnnotatedClass(annotationsComponent, container, "CXS_EventInput", CXSEventInput.class) - .description("The event input object to send events to the Context Server"); - - for (Map.Entry<String,CXSEventType> cxsEventTypeEntry : eventTypes.entrySet()) { - CXSEventType cxsEventType = cxsEventTypeEntry.getValue(); - cxsEventInputType.field(newInputObjectField() - .name(cxsEventTypeEntry.getKey()) - .type(buildCXSEventTypeInputProperty(cxsEventType.getTypeName(), cxsEventType.getProperties())) - ); - } - - return cxsEventInputType.build(); - - } - - private GraphQLInputType buildCXSEventTypeInputProperty(String typeName, List<CXSPropertyType> propertyTypes) { - String eventTypeName = typeName.substring(0, 1).toUpperCase() + typeName.substring(1) + "EventTypeInput"; - GraphQLInputObjectType.Builder eventInputType = newInputObject() - .name(eventTypeName) - .description("Event type object for event type " + typeName); - - for (CXSPropertyType cxsEventPropertyType : propertyTypes) { - GraphQLInputType eventPropertyInputType = null; - if (cxsEventPropertyType instanceof CXSIdentifierPropertyType) { - eventPropertyInputType = GraphQLID; - } else if (cxsEventPropertyType instanceof CXSStringPropertyType) { - eventPropertyInputType = GraphQLString; - } else if (cxsEventPropertyType instanceof CXSIntPropertyType) { - eventPropertyInputType = GraphQLInt; - } else if (cxsEventPropertyType instanceof CXSFloatPropertyType) { - eventPropertyInputType = GraphQLFloat; - } else if (cxsEventPropertyType instanceof CXSBooleanPropertyType) { - eventPropertyInputType = GraphQLBoolean; - } else if (cxsEventPropertyType instanceof CXSDatePropertyType) { - eventPropertyInputType = GraphQLString; - } else if (cxsEventPropertyType instanceof CXSGeoPointPropertyType) { - eventPropertyInputType = (GraphQLInputType) typeRegistry.get("CXS_GeoPoint"); - } else if (cxsEventPropertyType instanceof CXSSetPropertyType) { - eventPropertyInputType = buildCXSEventTypeInputProperty(cxsEventPropertyType.getName(), ((CXSSetPropertyType)cxsEventPropertyType).getProperties()); - } - eventInputType - .field(newInputObjectField() - .type(eventPropertyInputType) - .name(cxsEventPropertyType.getName()) - ); - } - - return eventInputType.build(); - } - - private GraphQLOutputType buildCXSEventOutputType() { - return newObject() - .name("CXS_Event") - .description("An event is generated by user interacting with the Context Server") - .field(newFieldDefinition() - .type(GraphQLID) - .name("id") - .description("A unique identifier for the event") - .dataFetcher(new DataFetcher() { - public Object get(DataFetchingEnvironment environment) { - CXSEvent CXSEvent = environment.getSource(); - return CXSEvent.getId(); - } - }) - ) - .field(newFieldDefinition() - .type(GraphQLString) - .name("eventType") - .description("An identifier for the event type") - .dataFetcher(new DataFetcher() { - public Object get(DataFetchingEnvironment environment) { - CXSEvent CXSEvent = environment.getSource(); - return CXSEvent.getEventType(); - } - }) - ) - .field(newFieldDefinition() - .type(GraphQLLong) - .name("timestamp") - .description("The difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC.") - .dataFetcher(new DataFetcher() { - public Object get(DataFetchingEnvironment environment) { - CXSEvent CXSEvent = environment.getSource(); - return CXSEvent.getTimeStamp(); - } - })) - .field(newFieldDefinition() - .type(GraphQLString) - .name("subject") - .description("The entity that has fired the event (using the profile)") - .dataFetcher(new DataFetcher() { - public Object get(DataFetchingEnvironment environment) { - CXSEvent CXSEvent = environment.getSource(); - return CXSEvent.getSubject(); - } - })) - .field(newFieldDefinition() - .type(GraphQLString) - .name("object") - .description("The object on which the event was fired.") - .dataFetcher(new DataFetcher() { - public Object get(DataFetchingEnvironment environment) { - CXSEvent CXSEvent = environment.getSource(); - return CXSEvent.getObject(); - } - }) - ) - .field(newFieldDefinition() - .type((GraphQLOutputType) typeRegistry.get("CXS_GeoPoint")) - .name("location") - .description("The geo-point location where the event was fired.") - .dataFetcher(new DataFetcher() { - public Object get(DataFetchingEnvironment environment) { - CXSEvent CXSEvent = environment.getSource(); - return CXSEvent.getLocation(); - } - }) - ) - .field(newFieldDefinition() - .type(new GraphQLList(typeRegistry.get("CXS_EventProperties"))) - .name("properties") - .description("Generic properties for the event") - .dataFetcher(new DataFetcher() { - public Object get(DataFetchingEnvironment environment) { - CXSEvent CXSEvent = environment.getSource(); - return new ArrayList<Map.Entry<Object,Object>>(CXSEvent.getProperties().getProperties().entrySet()); - } - }) - ) - .build(); - } - - private GraphQLOutputType buildCXSEventPropertiesOutputType() { - GraphQLObjectType.Builder eventPropertiesOutputType = CXSBuildersUtils.getOutputBuilderFromAnnotatedClass(annotationsComponent, container, "CXS_EventProperties", CXSEventProperties.class) - .description("All possible properties of an event"); - - for (Map.Entry<String,CXSEventType> cxsEventTypeEntry : eventTypes.entrySet()) { - CXSEventType cxsEventType = cxsEventTypeEntry.getValue(); - eventPropertiesOutputType - .field(newFieldDefinition() - .type(buildEventOutputType(cxsEventType.getTypeName(), cxsEventType.getProperties())) - .name(cxsEventTypeEntry.getKey()) - ); - } - - return eventPropertiesOutputType.build(); - } - - private GraphQLOutputType buildEventOutputType(String typeName, List<CXSPropertyType> propertyTypes) { - String eventTypeName = typeName.substring(0, 1).toUpperCase() + typeName.substring(1) + "EventType"; - GraphQLObjectType.Builder eventOutputType = newObject() - .name(eventTypeName) - .description("Event type object for event type " + typeName); - - for (CXSPropertyType cxsEventPropertyType : propertyTypes) { - GraphQLOutputType eventPropertyOutputType = null; - if (cxsEventPropertyType instanceof CXSIdentifierPropertyType) { - eventPropertyOutputType = GraphQLID; - } else if (cxsEventPropertyType instanceof CXSStringPropertyType) { - eventPropertyOutputType = GraphQLString; - } else if (cxsEventPropertyType instanceof CXSIntPropertyType) { - eventPropertyOutputType = GraphQLInt; - } else if (cxsEventPropertyType instanceof CXSFloatPropertyType) { - eventPropertyOutputType = GraphQLFloat; - } else if (cxsEventPropertyType instanceof CXSBooleanPropertyType) { - eventPropertyOutputType = GraphQLBoolean; - } else if (cxsEventPropertyType instanceof CXSDatePropertyType) { - eventPropertyOutputType = GraphQLString; - } else if (cxsEventPropertyType instanceof CXSGeoPointPropertyType) { - eventPropertyOutputType = (GraphQLOutputType) typeRegistry.get("CXS_GeoPoint"); - } else if (cxsEventPropertyType instanceof CXSSetPropertyType) { - eventPropertyOutputType = buildEventOutputType(cxsEventPropertyType.getName(), ((CXSSetPropertyType)cxsEventPropertyType).getProperties()); - } - eventOutputType - .field(newFieldDefinition() - .type(eventPropertyOutputType) - .name(cxsEventPropertyType.getName()) - ); - } - - - return eventOutputType.build(); - } - -}
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/cfc12dad/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/internal/CDPGraphQLProviderImpl.java ---------------------------------------------------------------------- diff --git a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/internal/CDPGraphQLProviderImpl.java b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/internal/CDPGraphQLProviderImpl.java new file mode 100644 index 0000000..62adf7f --- /dev/null +++ b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/internal/CDPGraphQLProviderImpl.java @@ -0,0 +1,245 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.unomi.graphql.internal; + +import graphql.annotations.processor.GraphQLAnnotationsComponent; +import graphql.annotations.processor.ProcessingElementsContainer; +import graphql.schema.*; +import graphql.servlet.GraphQLMutationProvider; +import graphql.servlet.GraphQLQueryProvider; +import graphql.servlet.GraphQLTypesProvider; +import org.apache.unomi.graphql.CDPGraphQLProvider; +import org.apache.unomi.graphql.CDPMutation; +import org.apache.unomi.graphql.CDPProviderManager; +import org.apache.unomi.graphql.CDPQuery; +import org.apache.unomi.graphql.builders.CDPEventBuilders; +import org.apache.unomi.graphql.propertytypes.CDPSetPropertyType; +import org.apache.unomi.graphql.types.input.CDPDateFilter; +import org.apache.unomi.graphql.types.input.CDPEventTypeInput; +import org.apache.unomi.graphql.types.input.CDPGeoDistanceInput; +import org.apache.unomi.graphql.types.input.CDPOrderByInput; +import org.apache.unomi.graphql.types.output.CDPEventType; +import org.apache.unomi.graphql.types.output.CDPGeoPoint; +import org.apache.unomi.graphql.types.output.PageInfo; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.*; + +import static graphql.Scalars.GraphQLInt; +import static graphql.Scalars.GraphQLString; +import static graphql.schema.GraphQLArgument.newArgument; +import static graphql.schema.GraphQLFieldDefinition.newFieldDefinition; +import static graphql.schema.GraphQLObjectType.newObject; + +public class CDPGraphQLProviderImpl implements CDPGraphQLProvider, GraphQLQueryProvider, GraphQLTypesProvider, GraphQLMutationProvider { + + private static final Logger logger = LoggerFactory.getLogger(CDPGraphQLProviderImpl.class.getName()); + + private CDPProviderManager cdpProviderManager; + private GraphQLAnnotationsComponent annotationsComponent; + private ProcessingElementsContainer container; + private CDPEventBuilders cdpEventBuilders; + private Map<String,GraphQLType> typeRegistry; + + private Map<String, CDPEventType> eventTypes = new TreeMap<>(); + + public CDPGraphQLProviderImpl(GraphQLAnnotationsComponent annotationsComponent) { + this.annotationsComponent = annotationsComponent; + container = annotationsComponent.createContainer(); + container.setInputPrefix(""); + container.setInputSuffix("Input"); + typeRegistry = container.getTypeRegistry(); + cdpEventBuilders = new CDPEventBuilders(annotationsComponent, container, eventTypes); + updateGraphQLTypes(); + } + + @Override + public Map<String, CDPEventType> getEventTypes() { + return eventTypes; + } + + public CDPProviderManager getCdpProviderManager() { + return cdpProviderManager; + } + + public void updateGraphQLTypes() { + typeRegistry.clear(); + typeRegistry.put(PageInfo.class.getName(), annotationsComponent.getOutputTypeProcessor().getOutputTypeOrRef(PageInfo.class, container)); + + typeRegistry.put("CDP_GeoPoint", annotationsComponent.getOutputTypeProcessor().getOutputTypeOrRef(CDPGeoPoint.class, container)); + typeRegistry.put("CDP_SetPropertyType",annotationsComponent.getOutputTypeProcessor().getOutputTypeOrRef(CDPSetPropertyType.class, container)); + typeRegistry.put("CDP_EventType", annotationsComponent.getOutputTypeProcessor().getOutputTypeOrRef(CDPEventType.class, container)); + + typeRegistry.put("CDP_GeoDistanceInput", annotationsComponent.getInputTypeProcessor().getInputTypeOrRef(CDPGeoDistanceInput.class, container)); + typeRegistry.put("CDP_DateFilterInput", annotationsComponent.getInputTypeProcessor().getInputTypeOrRef(CDPDateFilter.class, container)); + typeRegistry.put("CDP_EventTypeInput", annotationsComponent.getInputTypeProcessor().getInputTypeOrRef(CDPEventTypeInput.class, container)); + typeRegistry.put("CDP_OrderByInput", annotationsComponent.getInputTypeProcessor().getInputTypeOrRef(CDPOrderByInput.class, container)); + + cdpEventBuilders.updateTypes(); + + typeRegistry.put("CDP_Query", annotationsComponent.getOutputTypeProcessor().getOutputTypeOrRef(CDPQuery.class, container)); + typeRegistry.put("CDP_Mutation", annotationsComponent.getOutputTypeProcessor().getOutputTypeOrRef(CDPMutation.class, container)); + + } + + + private GraphQLOutputType getOutputTypeFromRegistry(String typeName) { + return (GraphQLOutputType) typeRegistry.get(typeName); + } + + private GraphQLInputObjectType getInputTypeFromRegistry(String typeName) { + return (GraphQLInputObjectType) typeRegistry.get(typeName); + } + + public void setCdpProviderManager(CDPProviderManager cdpProviderManager) { + this.cdpProviderManager = cdpProviderManager; + } + + @Override + public Collection<GraphQLFieldDefinition> getQueries() { + List<GraphQLFieldDefinition> fieldDefinitions = new ArrayList<GraphQLFieldDefinition>(); + final CDPGraphQLProvider cdpGraphQLProvider = this; + fieldDefinitions.add(newFieldDefinition() + .type(getOutputTypeFromRegistry("CDP_Query")) + .name("cdp") + .description("Root field for all CDP queries") + .dataFetcher(new DataFetcher<CDPGraphQLProvider>() { + public CDPGraphQLProvider get(DataFetchingEnvironment environment) { + return cdpGraphQLProvider; + } + }).build()); + return fieldDefinitions; + } + + @Override + public Collection<GraphQLType> getTypes() { + return new ArrayList<>(); + } + + @Override + public Collection<GraphQLFieldDefinition> getMutations() { + List<GraphQLFieldDefinition> fieldDefinitions = new ArrayList<GraphQLFieldDefinition>(); + final CDPGraphQLProvider cdpGraphQLProvider = this; + fieldDefinitions.add(newFieldDefinition() + .type(getOutputTypeFromRegistry("CDP_Mutation")) + .name("cdp") + .description("Root field for all CDP mutations") + .dataFetcher(new DataFetcher<CDPGraphQLProvider>() { + @Override + public CDPGraphQLProvider get(DataFetchingEnvironment environment) { + return cdpGraphQLProvider; + } + }).build()); + return fieldDefinitions; + } + + private GraphQLOutputType buildCDPQueryOutputType() { + return newObject() + .name("CDP_Query") + .description("Root CDP query type") + .field(newFieldDefinition() + .type(new GraphQLList(getOutputTypeFromRegistry("CDP_EventType"))) + .name("getEventTypes") + .description("Retrieves the list of all the declared CDP event types in the Apache Unomi server") + ) + .field(newFieldDefinition() + .type(new GraphQLList(getOutputTypeFromRegistry("CDP_Event"))) + .name("getEvent") + .description("Retrieves a specific event") + ) + .field(newFieldDefinition() + .type(new GraphQLList(getOutputTypeFromRegistry("CDP_EventConnection"))) + .name("findEvents") + .argument(newArgument() + .name("filter") + .type(getInputTypeFromRegistry("CDP_EventFilterInput")) + ) + .argument(newArgument() + .name("orderBy") + .type(getInputTypeFromRegistry("CDP_OrderByInput")) + ) + .argument(newArgument() + .name("first") + .type(GraphQLInt) + .description("Number of objects to retrieve starting at the after cursor position") + ) + .argument(newArgument() + .name("after") + .type(GraphQLString) + .description("Starting cursor location to retrieve the object from") + ) + .argument(newArgument() + .name("last") + .type(GraphQLInt) + .description("Number of objects to retrieve end at the before cursor position") + ) + .argument(newArgument() + .name("before") + .type(GraphQLString) + .description("End cursor location to retrieve the object from") + ) + .description("Retrieves the events that match the specified filters") + ) + .field(newFieldDefinition() + .type(getOutputTypeFromRegistry("CDP_Segment")) + .name("getSegment") + .argument(newArgument() + .name("segmentId") + .type(GraphQLString) + .description("Unique identifier for the segment") + ) + ) + /* + .field(newFieldDefinition() + .type(new GraphQLList(registeredOutputTypes.get("CDP_ProfileConnection"))) + .name("findProfiles") + .argument(newArgument() + .name("filter") + .type(registeredInputTypes.get("CDP_ProfileFilterInput")) + ) + .argument(newArgument() + .name("orderBy") + .type(registeredInputTypes.get(CDPOrderByInput.class.getName())) + ) + .argument(newArgument() + .name("first") + .type(GraphQLInt) + .description("Number of objects to retrieve starting at the after cursor position") + ) + .argument(newArgument() + .name("after") + .type(GraphQLString) + .description("Starting cursor location to retrieve the object from") + ) + .argument(newArgument() + .name("last") + .type(GraphQLInt) + .description("Number of objects to retrieve end at the before cursor position") + ) + .argument(newArgument() + .name("before") + .type(GraphQLString) + .description("End cursor location to retrieve the object from") + ) + .description("Retrieves the profiles that match the specified profiles") + ) + */ + .build(); + } + +} http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/cfc12dad/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/internal/CDPProviderManagerImpl.java ---------------------------------------------------------------------- diff --git a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/internal/CDPProviderManagerImpl.java b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/internal/CDPProviderManagerImpl.java new file mode 100644 index 0000000..e8b75f8 --- /dev/null +++ b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/internal/CDPProviderManagerImpl.java @@ -0,0 +1,111 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.unomi.graphql.internal; + +import graphql.annotations.processor.GraphQLAnnotationsComponent; +import graphql.annotations.processor.retrievers.GraphQLFieldRetriever; +import graphql.servlet.GraphQLMutationProvider; +import graphql.servlet.GraphQLQueryProvider; +import graphql.servlet.GraphQLTypesProvider; +import org.apache.unomi.api.services.SegmentService; +import org.apache.unomi.graphql.CDPGraphQLProvider; +import org.apache.unomi.graphql.CDPProviderManager; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceRegistration; +import org.osgi.service.component.ComponentContext; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Deactivate; +import org.osgi.service.component.annotations.Reference; + +import java.util.Map; + +@Component( + name="CDPProviderManager", + immediate = true +) +public class CDPProviderManagerImpl implements CDPProviderManager { + + private CDPGraphQLProvider cdpGraphQLProvider; + private GraphQLAnnotationsComponent annotationsComponent; + private GraphQLFieldRetriever graphQLFieldRetriever; + private SegmentService segmentService; + + private ServiceRegistration<?> providerSR; + private BundleContext bundleContext; + + @Reference + public void setAnnotationsComponent(GraphQLAnnotationsComponent annotationsComponent) { + this.annotationsComponent = annotationsComponent; + } + + @Reference + public void setGraphQLFieldRetriever(GraphQLFieldRetriever graphQLFieldRetriever) { + this.graphQLFieldRetriever = graphQLFieldRetriever; + if (graphQLFieldRetriever != null) { + graphQLFieldRetriever.setAlwaysPrettify(true); + } + } + + @Reference + public void setSegmentService(SegmentService segmentService) { + this.segmentService = segmentService; + } + + @Override + public SegmentService getSegmentService() { + return segmentService; + } + + @Activate + void activate( + ComponentContext componentContext, + BundleContext bundleContext, + Map<String,Object> config) { + this.bundleContext = bundleContext; + this.cdpGraphQLProvider = new CDPGraphQLProviderImpl(annotationsComponent); + this.cdpGraphQLProvider.setCdpProviderManager(this); + providerSR = bundleContext.registerService(new String[] { + GraphQLQueryProvider.class.getName(), + GraphQLTypesProvider.class.getName(), + GraphQLMutationProvider.class.getName() + }, cdpGraphQLProvider, null); + } + + @Deactivate + void deactivate( + ComponentContext componentContext, + BundleContext bundleContext, + Map<String,Object> config) { + providerSR.unregister(); + cdpGraphQLProvider.setCdpProviderManager(null); + cdpGraphQLProvider = null; + } + + public void refreshProviders() { + if (providerSR != null) { + providerSR.unregister(); + providerSR = null; + providerSR = bundleContext.registerService(new String[] { + GraphQLQueryProvider.class.getName(), + GraphQLTypesProvider.class.getName(), + GraphQLMutationProvider.class.getName() + }, cdpGraphQLProvider, null); + } + } + +} http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/cfc12dad/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/internal/CXSGraphQLProviderImpl.java ---------------------------------------------------------------------- diff --git a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/internal/CXSGraphQLProviderImpl.java b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/internal/CXSGraphQLProviderImpl.java deleted file mode 100644 index e5dc6ba..0000000 --- a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/internal/CXSGraphQLProviderImpl.java +++ /dev/null @@ -1,245 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.unomi.graphql.internal; - -import graphql.annotations.processor.GraphQLAnnotationsComponent; -import graphql.annotations.processor.ProcessingElementsContainer; -import graphql.schema.*; -import graphql.servlet.GraphQLMutationProvider; -import graphql.servlet.GraphQLQueryProvider; -import graphql.servlet.GraphQLTypesProvider; -import org.apache.unomi.graphql.CXSGraphQLProvider; -import org.apache.unomi.graphql.CXSMutation; -import org.apache.unomi.graphql.CXSProviderManager; -import org.apache.unomi.graphql.CXSQuery; -import org.apache.unomi.graphql.builders.CXSEventBuilders; -import org.apache.unomi.graphql.propertytypes.CXSSetPropertyType; -import org.apache.unomi.graphql.types.input.CXSDateFilter; -import org.apache.unomi.graphql.types.input.CXSEventTypeInput; -import org.apache.unomi.graphql.types.input.CXSGeoDistanceInput; -import org.apache.unomi.graphql.types.input.CXSOrderByInput; -import org.apache.unomi.graphql.types.output.CXSEventType; -import org.apache.unomi.graphql.types.output.CXSGeoPoint; -import org.apache.unomi.graphql.types.output.PageInfo; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.*; - -import static graphql.Scalars.GraphQLInt; -import static graphql.Scalars.GraphQLString; -import static graphql.schema.GraphQLArgument.newArgument; -import static graphql.schema.GraphQLFieldDefinition.newFieldDefinition; -import static graphql.schema.GraphQLObjectType.newObject; - -public class CXSGraphQLProviderImpl implements CXSGraphQLProvider, GraphQLQueryProvider, GraphQLTypesProvider, GraphQLMutationProvider { - - private static final Logger logger = LoggerFactory.getLogger(CXSGraphQLProviderImpl.class.getName()); - - private CXSProviderManager cxsProviderManager; - private GraphQLAnnotationsComponent annotationsComponent; - private ProcessingElementsContainer container; - private CXSEventBuilders cxsEventBuilders; - private Map<String,GraphQLType> typeRegistry; - - private Map<String, CXSEventType> eventTypes = new TreeMap<>(); - - public CXSGraphQLProviderImpl(GraphQLAnnotationsComponent annotationsComponent) { - this.annotationsComponent = annotationsComponent; - container = annotationsComponent.createContainer(); - container.setInputPrefix(""); - container.setInputSuffix("Input"); - typeRegistry = container.getTypeRegistry(); - cxsEventBuilders = new CXSEventBuilders(annotationsComponent, container, eventTypes); - updateGraphQLTypes(); - } - - @Override - public Map<String, CXSEventType> getEventTypes() { - return eventTypes; - } - - public CXSProviderManager getCxsProviderManager() { - return cxsProviderManager; - } - - public void updateGraphQLTypes() { - typeRegistry.clear(); - typeRegistry.put(PageInfo.class.getName(), annotationsComponent.getOutputTypeProcessor().getOutputTypeOrRef(PageInfo.class, container)); - - typeRegistry.put("CXS_GeoPoint", annotationsComponent.getOutputTypeProcessor().getOutputTypeOrRef(CXSGeoPoint.class, container)); - typeRegistry.put("CXS_SetPropertyType",annotationsComponent.getOutputTypeProcessor().getOutputTypeOrRef(CXSSetPropertyType.class, container)); - typeRegistry.put("CXS_EventType", annotationsComponent.getOutputTypeProcessor().getOutputTypeOrRef(CXSEventType.class, container)); - - typeRegistry.put("CXS_GeoDistanceInput", annotationsComponent.getInputTypeProcessor().getInputTypeOrRef(CXSGeoDistanceInput.class, container)); - typeRegistry.put("CXS_DateFilterInput", annotationsComponent.getInputTypeProcessor().getInputTypeOrRef(CXSDateFilter.class, container)); - typeRegistry.put("CXS_EventTypeInput", annotationsComponent.getInputTypeProcessor().getInputTypeOrRef(CXSEventTypeInput.class, container)); - typeRegistry.put("CXS_OrderByInput", annotationsComponent.getInputTypeProcessor().getInputTypeOrRef(CXSOrderByInput.class, container)); - - cxsEventBuilders.updateTypes(); - - typeRegistry.put("CXS_Query", annotationsComponent.getOutputTypeProcessor().getOutputTypeOrRef(CXSQuery.class, container)); - typeRegistry.put("CXS_Mutation", annotationsComponent.getOutputTypeProcessor().getOutputTypeOrRef(CXSMutation.class, container)); - - } - - - private GraphQLOutputType getOutputTypeFromRegistry(String typeName) { - return (GraphQLOutputType) typeRegistry.get(typeName); - } - - private GraphQLInputObjectType getInputTypeFromRegistry(String typeName) { - return (GraphQLInputObjectType) typeRegistry.get(typeName); - } - - public void setCxsProviderManager(CXSProviderManager cxsProviderManager) { - this.cxsProviderManager = cxsProviderManager; - } - - @Override - public Collection<GraphQLFieldDefinition> getQueries() { - List<GraphQLFieldDefinition> fieldDefinitions = new ArrayList<GraphQLFieldDefinition>(); - final CXSGraphQLProvider cxsGraphQLProvider = this; - fieldDefinitions.add(newFieldDefinition() - .type(getOutputTypeFromRegistry("CXS_Query")) - .name("cxs") - .description("Root field for all CXS queries") - .dataFetcher(new DataFetcher<CXSGraphQLProvider>() { - public CXSGraphQLProvider get(DataFetchingEnvironment environment) { - return cxsGraphQLProvider; - } - }).build()); - return fieldDefinitions; - } - - @Override - public Collection<GraphQLType> getTypes() { - return new ArrayList<>(); - } - - @Override - public Collection<GraphQLFieldDefinition> getMutations() { - List<GraphQLFieldDefinition> fieldDefinitions = new ArrayList<GraphQLFieldDefinition>(); - final CXSGraphQLProvider cxsGraphQLProvider = this; - fieldDefinitions.add(newFieldDefinition() - .type(getOutputTypeFromRegistry("CXS_Mutation")) - .name("cxs") - .description("Root field for all CXS mutations") - .dataFetcher(new DataFetcher<CXSGraphQLProvider>() { - @Override - public CXSGraphQLProvider get(DataFetchingEnvironment environment) { - return cxsGraphQLProvider; - } - }).build()); - return fieldDefinitions; - } - - private GraphQLOutputType buildCXSQueryOutputType() { - return newObject() - .name("CXS_Query") - .description("Root CXS query type") - .field(newFieldDefinition() - .type(new GraphQLList(getOutputTypeFromRegistry("CXS_EventType"))) - .name("getEventTypes") - .description("Retrieves the list of all the declared CXS event types in the Apache Unomi server") - ) - .field(newFieldDefinition() - .type(new GraphQLList(getOutputTypeFromRegistry("CXS_Event"))) - .name("getEvent") - .description("Retrieves a specific event") - ) - .field(newFieldDefinition() - .type(new GraphQLList(getOutputTypeFromRegistry("CXS_EventConnection"))) - .name("findEvents") - .argument(newArgument() - .name("filter") - .type(getInputTypeFromRegistry("CXS_EventFilterInput")) - ) - .argument(newArgument() - .name("orderBy") - .type(getInputTypeFromRegistry("CXS_OrderByInput")) - ) - .argument(newArgument() - .name("first") - .type(GraphQLInt) - .description("Number of objects to retrieve starting at the after cursor position") - ) - .argument(newArgument() - .name("after") - .type(GraphQLString) - .description("Starting cursor location to retrieve the object from") - ) - .argument(newArgument() - .name("last") - .type(GraphQLInt) - .description("Number of objects to retrieve end at the before cursor position") - ) - .argument(newArgument() - .name("before") - .type(GraphQLString) - .description("End cursor location to retrieve the object from") - ) - .description("Retrieves the events that match the specified filters") - ) - .field(newFieldDefinition() - .type(getOutputTypeFromRegistry("CXS_Segment")) - .name("getSegment") - .argument(newArgument() - .name("segmentId") - .type(GraphQLString) - .description("Unique identifier for the segment") - ) - ) - /* - .field(newFieldDefinition() - .type(new GraphQLList(registeredOutputTypes.get("CXS_ProfileConnection"))) - .name("findProfiles") - .argument(newArgument() - .name("filter") - .type(registeredInputTypes.get("CXS_ProfileFilterInput")) - ) - .argument(newArgument() - .name("orderBy") - .type(registeredInputTypes.get(CXSOrderByInput.class.getName())) - ) - .argument(newArgument() - .name("first") - .type(GraphQLInt) - .description("Number of objects to retrieve starting at the after cursor position") - ) - .argument(newArgument() - .name("after") - .type(GraphQLString) - .description("Starting cursor location to retrieve the object from") - ) - .argument(newArgument() - .name("last") - .type(GraphQLInt) - .description("Number of objects to retrieve end at the before cursor position") - ) - .argument(newArgument() - .name("before") - .type(GraphQLString) - .description("End cursor location to retrieve the object from") - ) - .description("Retrieves the profiles that match the specified profiles") - ) - */ - .build(); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/cfc12dad/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/internal/CXSProviderManagerImpl.java ---------------------------------------------------------------------- diff --git a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/internal/CXSProviderManagerImpl.java b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/internal/CXSProviderManagerImpl.java deleted file mode 100644 index cd7c56f..0000000 --- a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/internal/CXSProviderManagerImpl.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.unomi.graphql.internal; - -import graphql.annotations.processor.GraphQLAnnotationsComponent; -import graphql.annotations.processor.retrievers.GraphQLFieldRetriever; -import graphql.servlet.GraphQLMutationProvider; -import graphql.servlet.GraphQLQueryProvider; -import graphql.servlet.GraphQLTypesProvider; -import org.apache.unomi.api.services.SegmentService; -import org.apache.unomi.graphql.CXSGraphQLProvider; -import org.apache.unomi.graphql.CXSProviderManager; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceRegistration; -import org.osgi.service.component.ComponentContext; -import org.osgi.service.component.annotations.Activate; -import org.osgi.service.component.annotations.Component; -import org.osgi.service.component.annotations.Deactivate; -import org.osgi.service.component.annotations.Reference; - -import java.util.Map; - -@Component( - name="CXSProviderManager", - immediate = true -) -public class CXSProviderManagerImpl implements CXSProviderManager { - - private CXSGraphQLProvider cxsGraphQLProvider; - private GraphQLAnnotationsComponent annotationsComponent; - private GraphQLFieldRetriever graphQLFieldRetriever; - private SegmentService segmentService; - - private ServiceRegistration<?> providerSR; - private BundleContext bundleContext; - - @Reference - public void setAnnotationsComponent(GraphQLAnnotationsComponent annotationsComponent) { - this.annotationsComponent = annotationsComponent; - } - - @Reference - public void setGraphQLFieldRetriever(GraphQLFieldRetriever graphQLFieldRetriever) { - this.graphQLFieldRetriever = graphQLFieldRetriever; - if (graphQLFieldRetriever != null) { - graphQLFieldRetriever.setAlwaysPrettify(true); - } - } - - @Reference - public void setSegmentService(SegmentService segmentService) { - this.segmentService = segmentService; - } - - @Override - public SegmentService getSegmentService() { - return segmentService; - } - - @Activate - void activate( - ComponentContext componentContext, - BundleContext bundleContext, - Map<String,Object> config) { - this.bundleContext = bundleContext; - this.cxsGraphQLProvider = new CXSGraphQLProviderImpl(annotationsComponent); - this.cxsGraphQLProvider.setCxsProviderManager(this); - providerSR = bundleContext.registerService(new String[] { - GraphQLQueryProvider.class.getName(), - GraphQLTypesProvider.class.getName(), - GraphQLMutationProvider.class.getName() - }, cxsGraphQLProvider, null); - } - - @Deactivate - void deactivate( - ComponentContext componentContext, - BundleContext bundleContext, - Map<String,Object> config) { - providerSR.unregister(); - cxsGraphQLProvider.setCxsProviderManager(null); - cxsGraphQLProvider = null; - } - - public void refreshProviders() { - if (providerSR != null) { - providerSR.unregister(); - providerSR = null; - providerSR = bundleContext.registerService(new String[] { - GraphQLQueryProvider.class.getName(), - GraphQLTypesProvider.class.getName(), - GraphQLMutationProvider.class.getName() - }, cxsGraphQLProvider, null); - } - } - -} http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/cfc12dad/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CDPBooleanPropertyType.java ---------------------------------------------------------------------- diff --git a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CDPBooleanPropertyType.java b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CDPBooleanPropertyType.java new file mode 100644 index 0000000..f066102 --- /dev/null +++ b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CDPBooleanPropertyType.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.unomi.graphql.propertytypes; + +import graphql.annotations.annotationTypes.GraphQLField; +import graphql.annotations.annotationTypes.GraphQLName; + +import java.util.List; + +@GraphQLName("CDP_BooleanPropertyType") +public class CDPBooleanPropertyType extends CDPPropertyType { + + private Boolean defaultValue; + + public CDPBooleanPropertyType(@GraphQLName("id") String id, + @GraphQLName("name") String name, + @GraphQLName("minOccurrences") Integer minOccurrences, + @GraphQLName("maxOccurrences") Integer maxOccurrences, + @GraphQLName("tags") List<String> tags, + @GraphQLName("systemTags") List<String> systemTags, + @GraphQLName("personalData") Boolean personalData, + @GraphQLName("defaultValue") Boolean defaultValue) { + super(id, name, minOccurrences, maxOccurrences, tags, systemTags, personalData); + this.defaultValue = defaultValue; + } + + public CDPBooleanPropertyType(CDPPropertyType input, Boolean defaultValue) { + super(input); + this.defaultValue = defaultValue; + } + + @GraphQLField + @GraphQLName("defaultValue") + public Boolean isDefaultValue() { + return defaultValue; + } +} http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/cfc12dad/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CDPDatePropertyType.java ---------------------------------------------------------------------- diff --git a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CDPDatePropertyType.java b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CDPDatePropertyType.java new file mode 100644 index 0000000..cdac2c2 --- /dev/null +++ b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CDPDatePropertyType.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.unomi.graphql.propertytypes; + +import graphql.annotations.annotationTypes.GraphQLField; +import graphql.annotations.annotationTypes.GraphQLName; + +import java.util.List; + +@GraphQLName("CDP_DatePropertyType") +public class CDPDatePropertyType extends CDPPropertyType { + + private String defaultValue; + + public CDPDatePropertyType(@GraphQLName("id") String id, + @GraphQLName("name") String name, + @GraphQLName("minOccurrences") Integer minOccurrences, + @GraphQLName("maxOccurrences") Integer maxOccurrences, + @GraphQLName("tags") List<String> tags, + @GraphQLName("systemTags") List<String> systemTags, + @GraphQLName("personalData") Boolean personalData, + @GraphQLName("defaultValue") String defaultValue) { + super(id, name, minOccurrences, maxOccurrences, tags, systemTags, personalData); + this.defaultValue = defaultValue; + } + + @GraphQLField + public String getDefaultValue() { + return defaultValue; + } +} http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/cfc12dad/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CDPFloatPropertyType.java ---------------------------------------------------------------------- diff --git a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CDPFloatPropertyType.java b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CDPFloatPropertyType.java new file mode 100644 index 0000000..35f3b7d --- /dev/null +++ b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CDPFloatPropertyType.java @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.unomi.graphql.propertytypes; + +import graphql.annotations.annotationTypes.GraphQLField; +import graphql.annotations.annotationTypes.GraphQLName; + +import java.util.List; + +@GraphQLName("CDP_FloatPropertyType") +public class CDPFloatPropertyType extends CDPPropertyType { + + private Double minValue; + private Double maxValue; + private Double defaultValue; + + public CDPFloatPropertyType(@GraphQLName("id") String id, + @GraphQLName("name") String name, + @GraphQLName("minOccurrences") Integer minOccurrences, + @GraphQLName("maxOccurrences") Integer maxOccurrences, + @GraphQLName("tags") List<String> tags, + @GraphQLName("systemTags") List<String> systemTags, + @GraphQLName("personalData") Boolean personalData, + @GraphQLName("minValue") Double minValue, + @GraphQLName("maxValue") Double maxValue, + @GraphQLName("defaultValue") Double defaultValue) { + super(id, name, minOccurrences, maxOccurrences, tags, systemTags, personalData); + this.minValue = minValue; + this.maxValue = maxValue; + this.defaultValue = defaultValue; + } + + @GraphQLField + public Double getMinValue() { + return minValue; + } + + @GraphQLField + public Double getMaxValue() { + return maxValue; + } + + @GraphQLField + public Double getDefaultValue() { + return defaultValue; + } +} http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/cfc12dad/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CDPGeoPointPropertyType.java ---------------------------------------------------------------------- diff --git a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CDPGeoPointPropertyType.java b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CDPGeoPointPropertyType.java new file mode 100644 index 0000000..734bfd6 --- /dev/null +++ b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CDPGeoPointPropertyType.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.unomi.graphql.propertytypes; + +import graphql.annotations.annotationTypes.GraphQLField; +import graphql.annotations.annotationTypes.GraphQLName; + +import java.util.List; + +@GraphQLName("CDP_GeoPointPropertyType") +public class CDPGeoPointPropertyType extends CDPPropertyType { + + private String defaultValue; + + public CDPGeoPointPropertyType(@GraphQLName("id") String id, + @GraphQLName("name") String name, + @GraphQLName("minOccurrences") Integer minOccurrences, + @GraphQLName("maxOccurrences") Integer maxOccurrences, + @GraphQLName("tags") List<String> tags, + @GraphQLName("systemTags") List<String> systemTags, + @GraphQLName("personalData") Boolean personalData, + @GraphQLName("defaultValue") String defaultValue) { + super(id, name, minOccurrences, maxOccurrences, tags, systemTags, personalData); + this.defaultValue = defaultValue; + } + + @GraphQLField + public String getDefaultValue() { + return defaultValue; + } +} http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/cfc12dad/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CDPIdentifierPropertyType.java ---------------------------------------------------------------------- diff --git a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CDPIdentifierPropertyType.java b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CDPIdentifierPropertyType.java new file mode 100644 index 0000000..ab09a6b --- /dev/null +++ b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CDPIdentifierPropertyType.java @@ -0,0 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.unomi.graphql.propertytypes; + +import graphql.annotations.annotationTypes.GraphQLField; +import graphql.annotations.annotationTypes.GraphQLName; + +import java.util.List; + +@GraphQLName("CDP_IdentifierPropertyType") +public class CDPIdentifierPropertyType extends CDPPropertyType { + + private String regexp; + private String defaultValue; + + public CDPIdentifierPropertyType(@GraphQLName("id") String id, + @GraphQLName("name") String name, + @GraphQLName("minOccurrences") Integer minOccurrences, + @GraphQLName("maxOccurrences") Integer maxOccurrences, + @GraphQLName("tags") List<String> tags, + @GraphQLName("systemTags") List<String> systemTags, + @GraphQLName("personalData") Boolean personalData, + @GraphQLName("regexp") String regexp, + @GraphQLName("defaultValue") String defaultValue) { + super(id, name, minOccurrences, maxOccurrences, tags, systemTags, personalData); + this.regexp = regexp; + this.defaultValue = defaultValue; + } + + @GraphQLField + public String getRegexp() { + return regexp; + } + + @GraphQLField + public String getDefaultValue() { + return defaultValue; + } +} http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/cfc12dad/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CDPIntPropertyType.java ---------------------------------------------------------------------- diff --git a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CDPIntPropertyType.java b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CDPIntPropertyType.java new file mode 100644 index 0000000..100dd9a --- /dev/null +++ b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CDPIntPropertyType.java @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.unomi.graphql.propertytypes; + +import graphql.annotations.annotationTypes.GraphQLField; +import graphql.annotations.annotationTypes.GraphQLName; + +import java.util.List; + +@GraphQLName("CDP_IntPropertyType") +public class CDPIntPropertyType extends CDPPropertyType { + + private Integer minValue; + private Integer maxValue; + private Integer defaultValue; + + public CDPIntPropertyType(@GraphQLName("id") String id, + @GraphQLName("name") String name, + @GraphQLName("minOccurrences") Integer minOccurrences, + @GraphQLName("maxOccurrences") Integer maxOccurrences, + @GraphQLName("tags") List<String> tags, + @GraphQLName("systemTags") List<String> systemTags, + @GraphQLName("personalData") Boolean personalData, + @GraphQLName("minValue") Integer minValue, + @GraphQLName("maxValue") Integer maxValue, + @GraphQLName("defaultValue") Integer defaultValue) { + super(id, name, minOccurrences, maxOccurrences, tags, systemTags, personalData); + this.minValue = minValue; + this.maxValue = maxValue; + this.defaultValue = defaultValue; + } + + @GraphQLField + public Integer getMinValue() { + return minValue; + } + + @GraphQLField + public Integer getMaxValue() { + return maxValue; + } + + @GraphQLField + public Integer getDefaultValue() { + return defaultValue; + } +} http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/cfc12dad/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CDPPropertyType.java ---------------------------------------------------------------------- diff --git a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CDPPropertyType.java b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CDPPropertyType.java new file mode 100644 index 0000000..2851f08 --- /dev/null +++ b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CDPPropertyType.java @@ -0,0 +1,95 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.unomi.graphql.propertytypes; + +import graphql.annotations.annotationTypes.GraphQLField; +import graphql.annotations.annotationTypes.GraphQLName; + +import java.util.List; + +@GraphQLName("CDP_PropertyType") +public class CDPPropertyType { + + private String id; + private String name; + private Integer minOccurrences; + private Integer maxOccurrences; + private List<String> tags; + private List<String> systemTags; + private Boolean personalData; + + public CDPPropertyType(@GraphQLName("id") String id, + @GraphQLName("name") String name, + @GraphQLName("minOccurrences") Integer minOccurrences, + @GraphQLName("maxOccurrences") Integer maxOccurrences, + @GraphQLName("tags") List<String> tags, + @GraphQLName("systemTags") List<String> systemTags, + @GraphQLName("personalData") Boolean personalData) { + this.id = id; + this.name = name; + this.minOccurrences = minOccurrences; + this.maxOccurrences = maxOccurrences; + this.tags = tags; + this.systemTags = systemTags; + this.personalData = personalData; + } + + public CDPPropertyType(CDPPropertyType input) { + this.id = input.id; + this.name = input.name; + this.minOccurrences = input.minOccurrences; + this.maxOccurrences = input.maxOccurrences; + this.tags = input.tags; + this.systemTags = input.systemTags; + this.personalData = input.personalData; + } + + @GraphQLField + public String getId() { + return id; + } + + @GraphQLField + public String getName() { + return name; + } + + @GraphQLField + public Integer getMinOccurrences() { + return minOccurrences; + } + + @GraphQLField + public Integer getMaxOccurrences() { + return maxOccurrences; + } + + @GraphQLField + public List<String> getTags() { + return tags; + } + + @GraphQLField + public List<String> getSystemTags() { + return systemTags; + } + + @GraphQLField + public Boolean isPersonalData() { + return personalData; + } +} http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/cfc12dad/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CDPSetPropertyType.java ---------------------------------------------------------------------- diff --git a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CDPSetPropertyType.java b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CDPSetPropertyType.java new file mode 100644 index 0000000..bf1c52c --- /dev/null +++ b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CDPSetPropertyType.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.unomi.graphql.propertytypes; + +import graphql.annotations.annotationTypes.GraphQLField; +import graphql.annotations.annotationTypes.GraphQLName; + +import java.util.List; + +@GraphQLName("CDP_SetPropertyType") +public class CDPSetPropertyType extends CDPPropertyType { + + private List<CDPPropertyType> properties; + + public CDPSetPropertyType(@GraphQLName("id") String id, + @GraphQLName("name") String name, + @GraphQLName("minOccurrences") Integer minOccurrences, + @GraphQLName("maxOccurrences") Integer maxOccurrences, + @GraphQLName("tags") List<String> tags, + @GraphQLName("systemTags") List<String> systemTags, + @GraphQLName("personalData") Boolean personalData, + @GraphQLName("properties") List<CDPPropertyType> properties) { + super(id, name, minOccurrences, maxOccurrences, tags, systemTags, personalData); + this.properties = properties; + } + + @GraphQLField + public List<CDPPropertyType> getProperties() { + return properties; + } +} http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/cfc12dad/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CDPStringPropertyType.java ---------------------------------------------------------------------- diff --git a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CDPStringPropertyType.java b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CDPStringPropertyType.java new file mode 100644 index 0000000..7982c80 --- /dev/null +++ b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CDPStringPropertyType.java @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.unomi.graphql.propertytypes; + +import graphql.annotations.annotationTypes.GraphQLField; +import graphql.annotations.annotationTypes.GraphQLName; + +import java.util.List; + +@GraphQLName("CDP_StringPropertyType") +public class CDPStringPropertyType extends CDPPropertyType { + + private String regexp; + private String defaultValue; + + public CDPStringPropertyType(@GraphQLName("id") String id, + @GraphQLName("name") String name, + @GraphQLName("minOccurrences") Integer minOccurrences, + @GraphQLName("maxOccurrences") Integer maxOccurrences, + @GraphQLName("tags") List<String> tags, + @GraphQLName("systemTags") List<String> systemTags, + @GraphQLName("personalData") Boolean personalData, + @GraphQLName("regexp") String regexp, + @GraphQLName("defaultValue") String defaultValue) { + super(id, name, minOccurrences, maxOccurrences, tags, systemTags, personalData); + this.regexp = regexp; + this.defaultValue = defaultValue; + } + + @GraphQLField + public String getRegexp() { + return regexp; + } + + @GraphQLField + public String getDefaultValue() { + return defaultValue; + } + +} http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/cfc12dad/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CXSBooleanPropertyType.java ---------------------------------------------------------------------- diff --git a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CXSBooleanPropertyType.java b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CXSBooleanPropertyType.java deleted file mode 100644 index c50dd3b..0000000 --- a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CXSBooleanPropertyType.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.unomi.graphql.propertytypes; - -import graphql.annotations.annotationTypes.GraphQLField; -import graphql.annotations.annotationTypes.GraphQLName; - -import java.util.List; - -@GraphQLName("CXS_BooleanPropertyType") -public class CXSBooleanPropertyType extends CXSPropertyType { - - private Boolean defaultValue; - - public CXSBooleanPropertyType(@GraphQLName("id") String id, - @GraphQLName("name") String name, - @GraphQLName("minOccurrences") Integer minOccurrences, - @GraphQLName("maxOccurrences") Integer maxOccurrences, - @GraphQLName("tags") List<String> tags, - @GraphQLName("systemTags") List<String> systemTags, - @GraphQLName("personalData") Boolean personalData, - @GraphQLName("defaultValue") Boolean defaultValue) { - super(id, name, minOccurrences, maxOccurrences, tags, systemTags, personalData); - this.defaultValue = defaultValue; - } - - public CXSBooleanPropertyType(CXSPropertyType input, Boolean defaultValue) { - super(input); - this.defaultValue = defaultValue; - } - - @GraphQLField - @GraphQLName("defaultValue") - public Boolean isDefaultValue() { - return defaultValue; - } -}