This is an automated email from the ASF dual-hosted git repository. shuber pushed a commit to branch UNOMI-180-CXS-GRAPHQLAPI in repository https://gitbox.apache.org/repos/asf/unomi.git
commit 8b7d8d38eb132594b3b960fefcc6b6a47b7dc4cf Author: Serge Huber <shu...@apache.org> AuthorDate: Fri Jul 27 17:45:05 2018 +0200 UNOMI-180 Implement CXS GraphQL API Get event type creation to work (partially, the event GraphQL schema types are not yet properly modified) Signed-off-by: Serge Huber <shu...@apache.org> --- .../unomi/graphql/CXSBooleanPropertyType.java | 28 ----- .../apache/unomi/graphql/CXSDatePropertyType.java | 26 ----- .../org/apache/unomi/graphql/CXSEventType.java | 34 +++++- .../apache/unomi/graphql/CXSEventTypeInput.java | 33 +++++- .../apache/unomi/graphql/CXSFloatPropertyType.java | 30 ----- .../unomi/graphql/CXSGeoPointPropertyType.java | 25 ---- .../unomi/graphql/CXSIdentifierPropertyType.java | 28 ----- .../apache/unomi/graphql/CXSIntPropertyType.java | 30 ----- .../java/org/apache/unomi/graphql/CXSMutation.java | 88 +++++++------- .../org/apache/unomi/graphql/CXSPropertyType.java | 40 ------- .../apache/unomi/graphql/CXSPropertyTypeInput.java | 20 ++++ .../apache/unomi/graphql/CXSSetPropertyType.java | 27 ----- .../unomi/graphql/CXSSetPropertyTypeInput.java | 21 +++- .../unomi/graphql/CXSStringPropertyType.java | 28 ----- .../unomi/graphql/builders/CXSEventBuilders.java | 31 ++--- .../graphql/internal/CXSGraphQLProviderImpl.java | 127 ++------------------- .../graphql/internal/CXSProviderManagerImpl.java | 2 - .../propertytypes/CXSBooleanPropertyType.java | 51 +++++++++ .../CXSDatePropertyType.java} | 29 +++-- .../propertytypes/CXSFloatPropertyType.java | 60 ++++++++++ .../propertytypes/CXSGeoPointPropertyType.java | 44 +++++++ .../propertytypes/CXSIdentifierPropertyType.java | 52 +++++++++ .../graphql/propertytypes/CXSIntPropertyType.java | 60 ++++++++++ .../graphql/propertytypes/CXSPropertyType.java | 94 +++++++++++++++ .../graphql/propertytypes/CXSSetPropertyType.java | 44 +++++++ .../propertytypes/CXSStringPropertyType.java | 53 +++++++++ 26 files changed, 644 insertions(+), 461 deletions(-) diff --git a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/CXSBooleanPropertyType.java b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/CXSBooleanPropertyType.java deleted file mode 100644 index caea959..0000000 --- a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/CXSBooleanPropertyType.java +++ /dev/null @@ -1,28 +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; - -import graphql.annotations.annotationTypes.GraphQLField; -import graphql.annotations.annotationTypes.GraphQLName; - -@GraphQLName("CXSBooleanPropertyType") -public class CXSBooleanPropertyType extends CXSPropertyType { - - @GraphQLField - public boolean defaultValue; - -} diff --git a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/CXSDatePropertyType.java b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/CXSDatePropertyType.java deleted file mode 100644 index 362d2bc..0000000 --- a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/CXSDatePropertyType.java +++ /dev/null @@ -1,26 +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; - -import graphql.annotations.annotationTypes.GraphQLField; - -public class CXSDatePropertyType extends CXSPropertyType { - - @GraphQLField - public String defaultValue; - -} diff --git a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/CXSEventType.java b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/CXSEventType.java index a7c1c2c..2d4c5ae 100644 --- a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/CXSEventType.java +++ b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/CXSEventType.java @@ -18,22 +18,46 @@ package org.apache.unomi.graphql; import graphql.annotations.annotationTypes.GraphQLField; import graphql.annotations.annotationTypes.GraphQLName; +import org.apache.unomi.graphql.propertytypes.CXSPropertyType; +import java.util.ArrayList; import java.util.List; @GraphQLName("CXS_EventType") public class CXSEventType { - @GraphQLField - public String id; + private String id; + private String scope; + private String typeName; + private List<CXSPropertyType> properties = new ArrayList<>(); + + public CXSEventType(@GraphQLName("id") String id, + @GraphQLName("scope") String scope, + @GraphQLName("typeName") String typeName, + @GraphQLName("properties") List<CXSPropertyType> properties) { + this.id = id; + this.scope = scope; + this.typeName = typeName; + this.properties = properties; + } @GraphQLField - public String scope; + public String getId() { + return id; + } @GraphQLField - public String typeName; + public String getScope() { + return scope; + } @GraphQLField - public List<CXSPropertyType> properties; + public String getTypeName() { + return typeName; + } + @GraphQLField + public List<CXSPropertyType> getProperties() { + return properties; + } } diff --git a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/CXSEventTypeInput.java b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/CXSEventTypeInput.java index b84175f..a6f8200 100644 --- a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/CXSEventTypeInput.java +++ b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/CXSEventTypeInput.java @@ -17,20 +17,45 @@ package org.apache.unomi.graphql; import graphql.annotations.annotationTypes.GraphQLField; +import graphql.annotations.annotationTypes.GraphQLName; +import java.util.ArrayList; import java.util.List; public class CXSEventTypeInput { + private String id; + private String scope; + private String typeName; + private List<CXSPropertyTypeInput> properties = new ArrayList<>(); + + public CXSEventTypeInput(@GraphQLName("id") String id, + @GraphQLName("scope") String scope, + @GraphQLName("typeName") String typeName, + @GraphQLName("properties") List<CXSPropertyTypeInput> properties) { + this.id = id; + this.scope = scope; + this.typeName = typeName; + this.properties = properties; + } + @GraphQLField - public String id; + public String getId() { + return id; + } @GraphQLField - public String scope; + public String getScope() { + return scope; + } @GraphQLField - public String typeName; + public String getTypeName() { + return typeName; + } @GraphQLField - public List<CXSPropertyTypeInput> properties; + public List<CXSPropertyTypeInput> getProperties() { + return properties; + } } diff --git a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/CXSFloatPropertyType.java b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/CXSFloatPropertyType.java deleted file mode 100644 index 229b8db..0000000 --- a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/CXSFloatPropertyType.java +++ /dev/null @@ -1,30 +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; - -import graphql.annotations.annotationTypes.GraphQLField; - -public class CXSFloatPropertyType extends CXSPropertyType { - - @GraphQLField - public float minValue; - @GraphQLField - public float maxValue; - @GraphQLField - public float defaultValue; - -} diff --git a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/CXSGeoPointPropertyType.java b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/CXSGeoPointPropertyType.java deleted file mode 100644 index ce218c8..0000000 --- a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/CXSGeoPointPropertyType.java +++ /dev/null @@ -1,25 +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; - -import graphql.annotations.annotationTypes.GraphQLField; - -public class CXSGeoPointPropertyType extends CXSPropertyType { - - @GraphQLField - public String defaultValue; -} diff --git a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/CXSIdentifierPropertyType.java b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/CXSIdentifierPropertyType.java deleted file mode 100644 index 11f0742..0000000 --- a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/CXSIdentifierPropertyType.java +++ /dev/null @@ -1,28 +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; - -import graphql.annotations.annotationTypes.GraphQLField; - -public class CXSIdentifierPropertyType extends CXSPropertyType { - - @GraphQLField - public String regexp; - @GraphQLField - public String defaultValue; - -} diff --git a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/CXSIntPropertyType.java b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/CXSIntPropertyType.java deleted file mode 100644 index c7c904f..0000000 --- a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/CXSIntPropertyType.java +++ /dev/null @@ -1,30 +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; - -import graphql.annotations.annotationTypes.GraphQLField; - -public class CXSIntPropertyType extends CXSPropertyType { - - @GraphQLField - public int minValue; - @GraphQLField - public int maxValue; - @GraphQLField - public int defaultValue; - -} diff --git a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/CXSMutation.java b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/CXSMutation.java index e3a4dce..9732de4 100644 --- a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/CXSMutation.java +++ b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/CXSMutation.java @@ -19,6 +19,10 @@ package org.apache.unomi.graphql; import graphql.annotations.annotationTypes.GraphQLField; import graphql.annotations.annotationTypes.GraphQLName; import graphql.schema.DataFetchingEnvironment; +import org.apache.unomi.graphql.propertytypes.CXSIdentifierPropertyType; +import org.apache.unomi.graphql.propertytypes.CXSPropertyType; +import org.apache.unomi.graphql.propertytypes.CXSSetPropertyType; +import org.apache.unomi.graphql.propertytypes.CXSStringPropertyType; import java.util.ArrayList; import java.util.List; @@ -26,19 +30,21 @@ import java.util.List; @GraphQLName("CXS_Mutation") public class CXSMutation { + CXSGraphQLProvider cxsGraphQLProvider; + + public CXSMutation(CXSGraphQLProvider cxsGraphQLProvider) { + this.cxsGraphQLProvider = cxsGraphQLProvider; + } + @GraphQLField public CXSEventType createOrUpdateEventType(DataFetchingEnvironment env, @GraphQLName("eventType") CXSEventTypeInput cxsEventTypeInput) { - CXSGraphQLProvider cxsGraphQLProvider = null; - CXSEventType cxsEventType = new CXSEventType(); - cxsEventType.id = cxsEventTypeInput.id; - cxsEventType.typeName = cxsEventTypeInput.scope; - cxsEventType.properties = new ArrayList<>(); - for (CXSPropertyTypeInput propertyTypeInput : cxsEventTypeInput.properties) { + CXSEventType cxsEventType = new CXSEventType(cxsEventTypeInput.getId(), cxsEventTypeInput.getScope(), cxsEventTypeInput.getTypeName(), new ArrayList<>()); + for (CXSPropertyTypeInput propertyTypeInput : cxsEventTypeInput.getProperties()) { CXSPropertyType propertyType = getPropertyType(propertyTypeInput); - cxsEventType.properties.add(propertyType); + cxsEventType.getProperties().add(propertyType); } - cxsGraphQLProvider.getEventTypes().put(cxsEventType.typeName, cxsEventType); + cxsGraphQLProvider.getEventTypes().put(cxsEventType.getTypeName(), cxsEventType); cxsGraphQLProvider.updateGraphQLTypes(); if (cxsGraphQLProvider.getCxsProviderManager() != null) { cxsGraphQLProvider.getCxsProviderManager().refreshProviders(); @@ -65,49 +71,53 @@ public class CXSMutation { } private CXSPropertyType getSetPropertyType(CXSSetPropertyTypeInput cxsSetPropertyTypeInput) { - CXSSetPropertyType cxsSetPropertyType = new CXSSetPropertyType(); - - populateCommonProperties(cxsSetPropertyTypeInput, cxsSetPropertyType); - if (cxsSetPropertyTypeInput.properties != null) { - List<CXSPropertyType> setProperties = new ArrayList<>(); - for (CXSPropertyTypeInput setProperty : cxsSetPropertyTypeInput.properties) { + List<CXSPropertyType> setProperties = null; + if (cxsSetPropertyTypeInput.getProperties() != null) { + setProperties = new ArrayList<>(); + for (CXSPropertyTypeInput setProperty : cxsSetPropertyTypeInput.getProperties()) { CXSPropertyType subPropertyType = getPropertyType(setProperty); if (subPropertyType != null) { setProperties.add(subPropertyType); } } - cxsSetPropertyType.properties = setProperties; } - return cxsSetPropertyType; + return new CXSSetPropertyType( + cxsSetPropertyTypeInput.getId(), + cxsSetPropertyTypeInput.getName(), + cxsSetPropertyTypeInput.getMinOccurrences(), + cxsSetPropertyTypeInput.getMaxOccurrences(), + cxsSetPropertyTypeInput.getTags(), + cxsSetPropertyTypeInput.getSystemTags(), + cxsSetPropertyTypeInput.isPersonalData(), + setProperties); } private CXSPropertyType getStringPropertyType(CXSStringPropertyType stringPropertyType) { - CXSStringPropertyType cxsStringPropertyType = new CXSStringPropertyType(); - populateCommonProperties(stringPropertyType, cxsStringPropertyType); - cxsStringPropertyType.defaultValue = stringPropertyType.defaultValue; - cxsStringPropertyType.regexp = stringPropertyType.regexp; - return cxsStringPropertyType; + return new CXSStringPropertyType( + stringPropertyType.getId(), + stringPropertyType.getName(), + stringPropertyType.getMinOccurrences(), + stringPropertyType.getMaxOccurrences(), + stringPropertyType.getTags(), + stringPropertyType.getSystemTags(), + stringPropertyType.isPersonalData(), + stringPropertyType.getRegexp(), + stringPropertyType.getDefaultValue() + ); } private CXSPropertyType getIdentifierPropertyType(CXSIdentifierPropertyType identifierPropertyType) { - CXSIdentifierPropertyType cxsIdentifierPropertyType = new CXSIdentifierPropertyType(); - populateCommonProperties(identifierPropertyType, cxsIdentifierPropertyType); - cxsIdentifierPropertyType.defaultValue = identifierPropertyType.defaultValue; - cxsIdentifierPropertyType.regexp = identifierPropertyType.regexp; - return cxsIdentifierPropertyType; - } - - private void populateCommonProperties(CXSPropertyType source, CXSPropertyType destination) { - if (source == null) { - return; - } - destination.id = source.id; - destination.name = source.name; - destination.personalData = source.personalData; - destination.systemTags = source.systemTags; - destination.tags = source.tags; - destination.minOccurrences = source.minOccurrences; - destination.maxOccurrences = source.maxOccurrences; + return new CXSIdentifierPropertyType( + identifierPropertyType.getId(), + identifierPropertyType.getName(), + identifierPropertyType.getMinOccurrences(), + identifierPropertyType.getMaxOccurrences(), + identifierPropertyType.getTags(), + identifierPropertyType.getSystemTags(), + identifierPropertyType.isPersonalData(), + identifierPropertyType.getRegexp(), + identifierPropertyType.getDefaultValue() + ); } } diff --git a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/CXSPropertyType.java b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/CXSPropertyType.java deleted file mode 100644 index 641eff4..0000000 --- a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/CXSPropertyType.java +++ /dev/null @@ -1,40 +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; - -import graphql.annotations.annotationTypes.GraphQLField; - -import java.util.List; - -public class CXSPropertyType { - - @GraphQLField - public String id; - @GraphQLField - public String name; - @GraphQLField - public int minOccurrences; - @GraphQLField - public int maxOccurrences; - @GraphQLField - public List<String> tags; - @GraphQLField - public List<String> systemTags; - @GraphQLField - public boolean personalData; - -} diff --git a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/CXSPropertyTypeInput.java b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/CXSPropertyTypeInput.java index 48eadec..dda0ea4 100644 --- a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/CXSPropertyTypeInput.java +++ b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/CXSPropertyTypeInput.java @@ -18,10 +18,30 @@ package org.apache.unomi.graphql; import graphql.annotations.annotationTypes.GraphQLField; import graphql.annotations.annotationTypes.GraphQLName; +import org.apache.unomi.graphql.propertytypes.*; @GraphQLName("CXSPropertyTypeInput") public class CXSPropertyTypeInput { + public CXSPropertyTypeInput( + @GraphQLName("identifier") CXSIdentifierPropertyType identifierPropertyTypeInput, + @GraphQLName("string") CXSStringPropertyType stringPropertyTypeInput, + @GraphQLName("int") CXSIntPropertyType integerPropertyTypeInput, + @GraphQLName("float") CXSFloatPropertyType floatPropertyTypeInput, + @GraphQLName("date") CXSDatePropertyType datePropertyTypeInput, + @GraphQLName("boolean") CXSBooleanPropertyType booleanPropertyTypeInput, + @GraphQLName("geopoint") CXSGeoPointPropertyType geoPointPropertyTypeInput, + @GraphQLName("set") CXSSetPropertyTypeInput setPropertyTypeInput) { + this.identifierPropertyTypeInput = identifierPropertyTypeInput; + this.stringPropertyTypeInput = stringPropertyTypeInput; + this.integerPropertyTypeInput = integerPropertyTypeInput; + this.floatPropertyTypeInput = floatPropertyTypeInput; + this.datePropertyTypeInput = datePropertyTypeInput; + this.booleanPropertyTypeInput = booleanPropertyTypeInput; + this.geoPointPropertyTypeInput = geoPointPropertyTypeInput; + this.setPropertyTypeInput = setPropertyTypeInput; + } + @GraphQLField @GraphQLName("identifier") public CXSIdentifierPropertyType identifierPropertyTypeInput; diff --git a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/CXSSetPropertyType.java b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/CXSSetPropertyType.java deleted file mode 100644 index 3c054ae..0000000 --- a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/CXSSetPropertyType.java +++ /dev/null @@ -1,27 +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; - -import graphql.annotations.annotationTypes.GraphQLField; - -import java.util.List; - -public class CXSSetPropertyType extends CXSPropertyType { - - @GraphQLField - public List<CXSPropertyType> properties; -} diff --git a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/CXSSetPropertyTypeInput.java b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/CXSSetPropertyTypeInput.java index 2f0de04..8f32019 100644 --- a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/CXSSetPropertyTypeInput.java +++ b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/CXSSetPropertyTypeInput.java @@ -17,12 +17,29 @@ package org.apache.unomi.graphql; import graphql.annotations.annotationTypes.GraphQLField; +import graphql.annotations.annotationTypes.GraphQLName; +import org.apache.unomi.graphql.propertytypes.CXSPropertyType; import java.util.List; public class CXSSetPropertyTypeInput extends CXSPropertyType { - @GraphQLField - public List<CXSPropertyTypeInput> properties; + private List<CXSPropertyTypeInput> properties; + + public CXSSetPropertyTypeInput(@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<CXSPropertyTypeInput> properties) { + super(id, name, minOccurrences, maxOccurrences, tags, systemTags, personalData); + this.properties = properties; + } + @GraphQLField + public List<CXSPropertyTypeInput> getProperties() { + return properties; + } } diff --git a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/CXSStringPropertyType.java b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/CXSStringPropertyType.java deleted file mode 100644 index 2a4ef90..0000000 --- a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/CXSStringPropertyType.java +++ /dev/null @@ -1,28 +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; - -import graphql.annotations.annotationTypes.GraphQLField; - -public class CXSStringPropertyType extends CXSPropertyType { - - @GraphQLField - public String regexp; - @GraphQLField - public String defaultValue; - -} 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 index bc1d4f7..da5546a 100644 --- 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 @@ -20,6 +20,7 @@ import graphql.annotations.processor.GraphQLAnnotationsComponent; import graphql.annotations.processor.ProcessingElementsContainer; import graphql.schema.*; import org.apache.unomi.graphql.*; +import org.apache.unomi.graphql.propertytypes.*; import java.util.ArrayList; import java.util.List; @@ -116,7 +117,7 @@ public class CXSEventBuilders implements CXSBuilder { private void generateEventTypesFilters(GraphQLInputObjectType.Builder cxsEventPropertiesFilterInput) { for (Map.Entry<String,CXSEventType> eventTypeEntry : eventTypes.entrySet()) { - addSetFilters(eventTypeEntry.getKey(), eventTypeEntry.getValue().properties, cxsEventPropertiesFilterInput); + addSetFilters(eventTypeEntry.getKey(), eventTypeEntry.getValue().getProperties(), cxsEventPropertiesFilterInput); } } @@ -127,21 +128,21 @@ public class CXSEventBuilders implements CXSBuilder { for (CXSPropertyType cxsPropertyType : properties) { if (cxsPropertyType instanceof CXSIdentifierPropertyType) { - addIdentityFilters(cxsPropertyType.name, eventTypeFilterInput); + addIdentityFilters(cxsPropertyType.getName(), eventTypeFilterInput); } else if (cxsPropertyType instanceof CXSStringPropertyType) { - addStringFilters(cxsPropertyType.name, eventTypeFilterInput); + addStringFilters(cxsPropertyType.getName(), eventTypeFilterInput); } else if (cxsPropertyType instanceof CXSBooleanPropertyType) { - addBooleanFilters(cxsPropertyType.name, eventTypeFilterInput); + addBooleanFilters(cxsPropertyType.getName(), eventTypeFilterInput); } else if (cxsPropertyType instanceof CXSIntPropertyType) { - addIntegerFilters(cxsPropertyType.name, eventTypeFilterInput); + addIntegerFilters(cxsPropertyType.getName(), eventTypeFilterInput); } else if (cxsPropertyType instanceof CXSFloatPropertyType) { - addFloatFilters(cxsPropertyType.name, eventTypeFilterInput); + addFloatFilters(cxsPropertyType.getName(), eventTypeFilterInput); } else if (cxsPropertyType instanceof CXSGeoPointPropertyType) { - addDistanceFilters(cxsPropertyType.name, eventTypeFilterInput); + addDistanceFilters(cxsPropertyType.getName(), eventTypeFilterInput); } else if (cxsPropertyType instanceof CXSDatePropertyType) { - addDateFilters(cxsPropertyType.name, eventTypeFilterInput); + addDateFilters(cxsPropertyType.getName(), eventTypeFilterInput); } else if (cxsPropertyType instanceof CXSSetPropertyType) { - addSetFilters(cxsPropertyType.name, ((CXSSetPropertyType) cxsPropertyType).properties, eventTypeFilterInput); + addSetFilters(cxsPropertyType.getName(), ((CXSSetPropertyType) cxsPropertyType).getProperties(), eventTypeFilterInput); } } @@ -287,7 +288,7 @@ public class CXSEventBuilders implements CXSBuilder { CXSEventType cxsEventType = cxsEventTypeEntry.getValue(); cxsEventInputType.field(newInputObjectField() .name(cxsEventTypeEntry.getKey()) - .type(buildCXSEventTypeInputProperty(cxsEventType.typeName, cxsEventType.properties)) + .type(buildCXSEventTypeInputProperty(cxsEventType.getTypeName(), cxsEventType.getProperties())) ); } @@ -318,12 +319,12 @@ public class CXSEventBuilders implements CXSBuilder { } else if (cxsEventPropertyType instanceof CXSGeoPointPropertyType) { eventPropertyInputType = (GraphQLInputType) typeRegistry.get(CXSGeoPoint.class.getName()); } else if (cxsEventPropertyType instanceof CXSSetPropertyType) { - eventPropertyInputType = buildCXSEventTypeInputProperty(cxsEventPropertyType.name, ((CXSSetPropertyType)cxsEventPropertyType).properties); + eventPropertyInputType = buildCXSEventTypeInputProperty(cxsEventPropertyType.getName(), ((CXSSetPropertyType)cxsEventPropertyType).getProperties()); } eventInputType .field(newInputObjectField() .type(eventPropertyInputType) - .name(cxsEventPropertyType.name) + .name(cxsEventPropertyType.getName()) ); } @@ -428,7 +429,7 @@ public class CXSEventBuilders implements CXSBuilder { CXSEventType cxsEventType = cxsEventTypeEntry.getValue(); eventPropertiesOutputType .field(newFieldDefinition() - .type(buildEventOutputType(cxsEventType.typeName, cxsEventType.properties)) + .type(buildEventOutputType(cxsEventType.getTypeName(), cxsEventType.getProperties())) .name(cxsEventTypeEntry.getKey()) ); } @@ -459,12 +460,12 @@ public class CXSEventBuilders implements CXSBuilder { } else if (cxsEventPropertyType instanceof CXSGeoPointPropertyType) { eventPropertyOutputType = (GraphQLOutputType) typeRegistry.get(CXSGeoPoint.class.getName()); } else if (cxsEventPropertyType instanceof CXSSetPropertyType) { - eventPropertyOutputType = buildEventOutputType(cxsEventPropertyType.name, ((CXSSetPropertyType)cxsEventPropertyType).properties); + eventPropertyOutputType = buildEventOutputType(cxsEventPropertyType.getName(), ((CXSSetPropertyType)cxsEventPropertyType).getProperties()); } eventOutputType .field(newFieldDefinition() .type(eventPropertyOutputType) - .name(cxsEventPropertyType.name) + .name(cxsEventPropertyType.getName()) ); } 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 index a3c299d..949f51e 100644 --- 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 @@ -24,6 +24,7 @@ import graphql.servlet.GraphQLQueryProvider; import graphql.servlet.GraphQLTypesProvider; import org.apache.unomi.graphql.*; import org.apache.unomi.graphql.builders.CXSEventBuilders; +import org.apache.unomi.graphql.propertytypes.CXSSetPropertyType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -113,12 +114,13 @@ public class CXSGraphQLProviderImpl implements CXSGraphQLProvider, GraphQLQueryP .type(getOutputTypeFromRegistry("CXS_Query")) .name("cxs") .description("Root field for all CXS queries") + /* .dataFetcher(new DataFetcher() { public Object get(DataFetchingEnvironment environment) { Map<String,Object> map = environment.getContext(); return map.keySet(); } - }).build()); + })*/.build()); return fieldDefinitions; } @@ -130,15 +132,15 @@ public class CXSGraphQLProviderImpl implements CXSGraphQLProvider, GraphQLQueryP @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<Object>() { + .dataFetcher(new DataFetcher<CXSGraphQLProvider>() { @Override - public Object get(DataFetchingEnvironment environment) { - Object contextObject = environment.getContext(); - return contextObject; + public CXSGraphQLProvider get(DataFetchingEnvironment environment) { + return cxsGraphQLProvider; } }).build()); return fieldDefinitions; @@ -238,119 +240,4 @@ public class CXSGraphQLProviderImpl implements CXSGraphQLProvider, GraphQLQueryP .build(); } - private GraphQLOutputType buildCXSMutationOutputType() { - return newObject() - .name("CXS_Mutation") - .description("Root CXS mutation type") - .field(newFieldDefinition() - .type(getOutputTypeFromRegistry(CXSEventType.class.getName())) - .name("createOrUpdateEventType") - .argument(newArgument() - .name("eventType") - .type(getInputTypeFromRegistry(CXSEventTypeInput.class.getName())) - ) - .description("Create or updates a CXS event type in the Apache Unomi server") - .dataFetcher(new DataFetcher<CXSEventType>() { - @Override - public CXSEventType get(DataFetchingEnvironment environment) { - Map<String,Object> arguments = environment.getArguments(); - CXSEventType cxsEventType = new CXSEventType(); - if (arguments.containsKey("eventType")) { - Map<String,Object> eventTypeArguments = (Map<String,Object>) arguments.get("eventType"); - if (eventTypeArguments.containsKey("typeName")) { - cxsEventType.id = (String) eventTypeArguments.get("typeName"); - cxsEventType.typeName = (String) eventTypeArguments.get("typeName"); - } - cxsEventType.properties = new ArrayList<>(); - if (eventTypeArguments.containsKey("properties")) { - List<Map<String, Object>> properties = (List<Map<String, Object>>) eventTypeArguments.get("properties"); - for (Map<String, Object> propertyTypeMap : properties) { - CXSPropertyType cxsPropertyType = getPropertyType(propertyTypeMap); - if (cxsPropertyType != null) { - cxsEventType.properties.add(cxsPropertyType); - } - } - } - } - eventTypes.put(cxsEventType.typeName, cxsEventType); - updateGraphQLTypes(); - if (cxsProviderManager != null) { - cxsProviderManager.refreshProviders(); - } - return cxsEventType; - } - }) - ) - .field(newFieldDefinition() - .name("processEvents") - .description("Processes events sent to the Context Server") - .argument(newArgument() - .name("events") - .type(new GraphQLList(getInputTypeFromRegistry("CXS_EventInput")))) - .type(GraphQLInt) - ) - .build(); - } - - private CXSPropertyType getPropertyType(Map<String, Object> propertyTypeMap) { - if (propertyTypeMap.size() > 1) { - logger.error("Only one property type is allowed for each property !"); - return null; - } - CXSPropertyType propertyType = null; - if (propertyTypeMap.containsKey("identifier")) { - propertyType = getIdentifierPropertyType(propertyTypeMap); - } else if (propertyTypeMap.containsKey("string")) { - propertyType = getStringPropertyType(propertyTypeMap); - } else if (propertyTypeMap.containsKey("set")) { - propertyType = getSetPropertyType(propertyTypeMap); - } - return propertyType; - } - - private CXSPropertyType getSetPropertyType(Map<String, Object> propertyTypeMap) { - CXSSetPropertyType cxsSetPropertyType = new CXSSetPropertyType(); - Map<String,Object> setPropertyTypeMap = (Map<String,Object>) propertyTypeMap.get("set"); - populateCommonProperties(setPropertyTypeMap, cxsSetPropertyType); - if (setPropertyTypeMap.containsKey("properties")) { - List<Map<String,Object>> propertyList = (List<Map<String,Object>>) setPropertyTypeMap.get("properties"); - List<CXSPropertyType> setProperties = new ArrayList<>(); - for (Map<String,Object> setProperty : propertyList) { - CXSPropertyType subPropertyType = getPropertyType(setProperty); - if (subPropertyType != null) { - setProperties.add(subPropertyType); - } - } - cxsSetPropertyType.properties = setProperties; - } - return cxsSetPropertyType; - } - - private CXSPropertyType getStringPropertyType(Map<String, Object> propertyTypeMap) { - CXSStringPropertyType cxsStringPropertyType = new CXSStringPropertyType(); - Map<String,Object> stringPropertyTypeMap = (Map<String,Object>) propertyTypeMap.get("string"); - populateCommonProperties(stringPropertyTypeMap, cxsStringPropertyType); - return cxsStringPropertyType; - } - - private CXSPropertyType getIdentifierPropertyType(Map<String, Object> propertyTypeMap) { - CXSIdentifierPropertyType cxsIdentifierPropertyType = new CXSIdentifierPropertyType(); - Map<String,Object> identifierPropertyTypeMap = (Map<String,Object>) propertyTypeMap.get("identifier"); - populateCommonProperties(identifierPropertyTypeMap, cxsIdentifierPropertyType); - return cxsIdentifierPropertyType; - } - - private void populateCommonProperties(Map<String, Object> propertyTypeMap, CXSPropertyType cxsPropertyType) { - if (propertyTypeMap == null || propertyTypeMap.size() == 0) { - return; - } - if (propertyTypeMap.containsKey("id")) { - cxsPropertyType.id = (String) propertyTypeMap.get("id"); - } - if (propertyTypeMap.containsKey("name")) { - cxsPropertyType.name = (String) propertyTypeMap.get("name"); - } - } - - } 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 index bb00d54..99d9d1f 100644 --- 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 @@ -17,7 +17,6 @@ package org.apache.unomi.graphql.internal; import graphql.annotations.processor.GraphQLAnnotationsComponent; -import graphql.annotations.processor.ProcessingElementsContainer; import graphql.servlet.GraphQLMutationProvider; import graphql.servlet.GraphQLQueryProvider; import graphql.servlet.GraphQLTypesProvider; @@ -41,7 +40,6 @@ public class CXSProviderManagerImpl implements CXSProviderManager { private CXSGraphQLProvider cxsGraphQLProvider; private GraphQLAnnotationsComponent annotationsComponent; - private ProcessingElementsContainer container; private ServiceRegistration<?> providerSR; private BundleContext bundleContext; 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 new file mode 100644 index 0000000..75bc309 --- /dev/null +++ b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CXSBooleanPropertyType.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("CXSBooleanPropertyType") +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; + } +} diff --git a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/CXSEventType.java b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CXSDatePropertyType.java similarity index 50% copy from graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/CXSEventType.java copy to graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CXSDatePropertyType.java index a7c1c2c..4b4b403 100644 --- a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/CXSEventType.java +++ b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CXSDatePropertyType.java @@ -14,26 +14,31 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.unomi.graphql; +package org.apache.unomi.graphql.propertytypes; import graphql.annotations.annotationTypes.GraphQLField; import graphql.annotations.annotationTypes.GraphQLName; import java.util.List; -@GraphQLName("CXS_EventType") -public class CXSEventType { +public class CXSDatePropertyType extends CXSPropertyType { - @GraphQLField - public String id; + private String defaultValue; - @GraphQLField - public String scope; + public CXSDatePropertyType(@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 typeName; - - @GraphQLField - public List<CXSPropertyType> properties; - + public String getDefaultValue() { + return defaultValue; + } } diff --git a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CXSFloatPropertyType.java b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CXSFloatPropertyType.java new file mode 100644 index 0000000..6a37058 --- /dev/null +++ b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CXSFloatPropertyType.java @@ -0,0 +1,60 @@ +/* + * 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; + +public class CXSFloatPropertyType extends CXSPropertyType { + + private Float minValue; + private Float maxValue; + private Float defaultValue; + + public CXSFloatPropertyType(@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") Float minValue, + @GraphQLName("maxValue") Float maxValue, + @GraphQLName("defaultValue") Float defaultValue) { + super(id, name, minOccurrences, maxOccurrences, tags, systemTags, personalData); + this.minValue = minValue; + this.maxValue = maxValue; + this.defaultValue = defaultValue; + } + + @GraphQLField + public Float getMinValue() { + return minValue; + } + + @GraphQLField + public Float getMaxValue() { + return maxValue; + } + + @GraphQLField + public Float getDefaultValue() { + return defaultValue; + } +} diff --git a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CXSGeoPointPropertyType.java b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CXSGeoPointPropertyType.java new file mode 100644 index 0000000..94f2d97 --- /dev/null +++ b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CXSGeoPointPropertyType.java @@ -0,0 +1,44 @@ +/* + * 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; + +public class CXSGeoPointPropertyType extends CXSPropertyType { + + private String defaultValue; + + public CXSGeoPointPropertyType(@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; + } +} diff --git a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CXSIdentifierPropertyType.java b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CXSIdentifierPropertyType.java new file mode 100644 index 0000000..7207740 --- /dev/null +++ b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CXSIdentifierPropertyType.java @@ -0,0 +1,52 @@ +/* + * 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; + +public class CXSIdentifierPropertyType extends CXSPropertyType { + + private String regexp; + private String defaultValue; + + public CXSIdentifierPropertyType(@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; + } +} diff --git a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CXSIntPropertyType.java b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CXSIntPropertyType.java new file mode 100644 index 0000000..96c3322 --- /dev/null +++ b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CXSIntPropertyType.java @@ -0,0 +1,60 @@ +/* + * 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; + +public class CXSIntPropertyType extends CXSPropertyType { + + private Integer minValue; + private Integer maxValue; + private Integer defaultValue; + + public CXSIntPropertyType(@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; + } +} diff --git a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CXSPropertyType.java b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CXSPropertyType.java new file mode 100644 index 0000000..28aaf7e --- /dev/null +++ b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CXSPropertyType.java @@ -0,0 +1,94 @@ +/* + * 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; + +public class CXSPropertyType { + + private String id; + private String name; + private Integer minOccurrences; + private Integer maxOccurrences; + private List<String> tags; + private List<String> systemTags; + private Boolean personalData; + + public CXSPropertyType(@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 CXSPropertyType(CXSPropertyType 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; + } +} diff --git a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CXSSetPropertyType.java b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CXSSetPropertyType.java new file mode 100644 index 0000000..25e796c --- /dev/null +++ b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CXSSetPropertyType.java @@ -0,0 +1,44 @@ +/* + * 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; + +public class CXSSetPropertyType extends CXSPropertyType { + + private List<CXSPropertyType> properties; + + public CXSSetPropertyType(@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<CXSPropertyType> properties) { + super(id, name, minOccurrences, maxOccurrences, tags, systemTags, personalData); + this.properties = properties; + } + + @GraphQLField + public List<CXSPropertyType> getProperties() { + return properties; + } +} diff --git a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CXSStringPropertyType.java b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CXSStringPropertyType.java new file mode 100644 index 0000000..7736d09 --- /dev/null +++ b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/propertytypes/CXSStringPropertyType.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; + +public class CXSStringPropertyType extends CXSPropertyType { + + private String regexp; + private String defaultValue; + + public CXSStringPropertyType(@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; + } + +}