org.apache.olingo.odata2.api.edm.provider.Facets Java Examples

The following examples show how to use org.apache.olingo.odata2.api.edm.provider.Facets. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Sparql.java    From DataHubSystem with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public FunctionImport getFunctionImport()
{
   // Returns the Result Set of the given query as String.
   ReturnType rt = new ReturnType()
         .setMultiplicity(EdmMultiplicity.ZERO_TO_ONE)
         .setTypeName(EdmSimpleTypeKind.String.getFullQualifiedName());

   // One required param: the SPARQL query.
   List<FunctionImportParameter> params = new ArrayList<>();
   params.add(new FunctionImportParameter()
         .setName("query")
         .setType(EdmSimpleTypeKind.String)
         .setFacets(new Facets().setNullable(false)));

   return new FunctionImport()
         .setName(NAME)
         .setHttpMethod("GET")
         .setParameters(params)
         .setReturnType(rt);
}
 
Example #2
Source File: JPAEdmProperty.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
private SimpleProperty buildSimpleProperty(final Attribute<?, ?> jpaAttribute, final SimpleProperty simpleProperty,
    final JoinColumn joinColumn)
    throws ODataJPAModelException, ODataJPARuntimeException {

  boolean isForeignKey = joinColumn != null;
  JPAEdmNameBuilder.build(JPAEdmProperty.this, isBuildModeComplexType, skipDefaultNaming, isForeignKey);
  EdmSimpleTypeKind simpleTypeKind = JPATypeConverter
      .convertToEdmSimpleType(jpaAttribute
          .getJavaType(), jpaAttribute);
  simpleProperty.setType(simpleTypeKind);
  Facets facets = JPAEdmFacets.createAndSet(jpaAttribute, simpleProperty);
  if(isForeignKey) {
    facets.setNullable(joinColumn.nullable());
  }

  return simpleProperty;

}
 
Example #3
Source File: JPAEdmKey.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
public void normalizeComplexKey(final ComplexType complexType, final List<PropertyRef> propertyRefList) {
  for (Property property : complexType.getProperties()) {
    try {

      SimpleProperty simpleProperty = (SimpleProperty) property;
      Facets facets = (Facets) simpleProperty.getFacets();
      if (facets == null) {
        simpleProperty.setFacets(new Facets().setNullable(false));
      } else {
        facets.setNullable(false);
      }
      PropertyRef propertyRef = new PropertyRef();
      propertyRef.setName(simpleProperty.getName());
      propertyRefList.add(propertyRef);

    } catch (ClassCastException e) {
      ComplexProperty complexProperty = (ComplexProperty) property;
      normalizeComplexKey(complexTypeView.searchEdmComplexType(complexProperty.getType()), propertyRefList);
    }

  }
}
 
Example #4
Source File: AnnotationEdmProvider.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
private Facets createFacets(final EdmFacets facets, final EdmConcurrencyControl concurrencyControl) {
  Facets resultFacets = new Facets().setNullable(facets.nullable());
  if(facets.maxLength() > -1) {
    resultFacets.setMaxLength(facets.maxLength());
  }
  if(facets.precision() > -1) {
    resultFacets.setPrecision(facets.precision());
  }
  if(facets.scale() > -1) {
    resultFacets.setScale(facets.scale());
  }
  if (concurrencyControl != null) {
    resultFacets.setConcurrencyMode(EdmConcurrencyMode.Fixed);
  }
  return resultFacets;
}
 
Example #5
Source File: ItemEntitySet.java    From DataHubSystem with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public EntityType getEntityType ()
{
   List<Property> properties = new ArrayList<Property> ();
   properties.add (new SimpleProperty ().setName (ID)
      .setType (EdmSimpleTypeKind.String)
      .setFacets (new Facets ().setNullable (false)));
   properties.add (new SimpleProperty ()
      .setName (NAME)
      .setType (EdmSimpleTypeKind.String)
      .setCustomizableFeedMappings (
         new CustomizableFeedMappings ()
            .setFcTargetPath (EdmTargetPath.SYNDICATION_TITLE)));
   properties.add (new SimpleProperty ().setName (CONTENT_TYPE).setType (
      EdmSimpleTypeKind.String));
   properties.add (new SimpleProperty ().setName (CONTENT_LENGTH).setType (
      EdmSimpleTypeKind.Int64));

   // Key
   Key key =
      new Key ().setKeys (Collections.singletonList (new PropertyRef ()
         .setName (ID)));

   // TODO (OData v3) setOpenType(true) setAbstract(true)
   return new EntityType ().setName (ENTITY_NAME).setProperties (properties)
      .setKey (key);
}
 
Example #6
Source File: EdmPropertyImplProvTest.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setup() throws Exception {

  edmProvider = mock(EdmProvider.class);
  EdmImplProv edmImplProv = new EdmImplProv(edmProvider);

  Mapping propertySimpleMapping = new Mapping().setInternalName("value");
  CustomizableFeedMappings propertySimpleFeedMappings = new CustomizableFeedMappings().setFcKeepInContent(true);
  SimpleProperty propertySimple =
      new SimpleProperty().setName("PropertyName").setType(EdmSimpleTypeKind.String)
          .setMimeType("mimeType").setMapping(propertySimpleMapping).setCustomizableFeedMappings(
              propertySimpleFeedMappings);
  propertySimpleProvider = new EdmSimplePropertyImplProv(edmImplProv, propertySimple);

  Facets facets = new Facets().setNullable(false);
  SimpleProperty propertySimpleWithFacets =
      new SimpleProperty().setName("PropertyName").setType(EdmSimpleTypeKind.String).setFacets(facets);
  propertySimpleWithFacetsProvider = new EdmSimplePropertyImplProv(edmImplProv, propertySimpleWithFacets);

  Facets facets2 = new Facets().setNullable(true);
  SimpleProperty propertySimpleWithFacets2 =
      new SimpleProperty().setName("PropertyName").setType(EdmSimpleTypeKind.String).setFacets(facets2);
  propertySimpleWithFacetsProvider2 = new EdmSimplePropertyImplProv(edmImplProv, propertySimpleWithFacets2);

  ComplexType complexType = new ComplexType().setName("complexType");
  FullQualifiedName complexName = new FullQualifiedName("namespace", "complexType");
  when(edmProvider.getComplexType(complexName)).thenReturn(complexType);

  ComplexProperty propertyComplex = new ComplexProperty().setName("complexProperty").setType(complexName);
  propertyComplexProvider = new EdmComplexPropertyImplProv(edmImplProv, propertyComplex);

}
 
Example #7
Source File: ODataJPAResponseBuilderTest.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
private EdmProperty getEdmPropertyForSelect() {
  EdmSimpleType edmType = EasyMock.createMock(EdmSimpleType.class);
  EasyMock.expect(edmType.getKind()).andStubReturn(EdmTypeKind.SIMPLE);
  Facets facets = new Facets().setNullable(false);
  try {
    EasyMock.expect(edmType.valueToString(new Integer(2), EdmLiteralKind.URI, facets)).andStubReturn("2");
    EasyMock.expect(edmType.valueToString(new Integer(2), EdmLiteralKind.DEFAULT, facets)).andStubReturn("2");
  } catch (EdmSimpleTypeException e1) {
    fail("There is an exception in mocking EdmType object " + e1.getMessage());
  }
  EasyMock.replay(edmType);
  EdmProperty edmProperty = EasyMock.createMock(EdmProperty.class);
  JPAEdmMappingImpl edmMapping = EasyMock.createMock(JPAEdmMappingImpl.class);
  EasyMock.expect(edmMapping.getInternalName()).andStubReturn("soId");
  EasyMock.expect(edmMapping.getMediaResourceMimeTypeKey()).andReturn(null);
  EasyMock.expect(((JPAEdmMappingImpl) edmMapping).isVirtualAccess()).andStubReturn(false);
  EasyMock.replay(edmMapping);
  try {
    EasyMock.expect(edmProperty.getName()).andStubReturn("ID");
    EasyMock.expect(edmProperty.getType()).andStubReturn(edmType);
    EasyMock.expect(edmProperty.getMapping()).andStubReturn(edmMapping);
    EasyMock.expect(edmProperty.getFacets()).andStubReturn(facets);
    EasyMock.expect(edmProperty.getCustomizableFeedMappings()).andStubReturn(null);
    EasyMock.expect(edmProperty.getMimeType()).andStubReturn(null);
    EasyMock.replay(edmProperty);

  } catch (EdmException e) {
    fail("There is an exception in mocking some object " + e.getMessage());
  }

  return edmProperty;

}
 
Example #8
Source File: SystemRoleEntitySet.java    From DataHubSystem with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public EntityType getEntityType ()
{
   Key key = new Key ();
   List<PropertyRef> property_refs =
         Collections.singletonList (new PropertyRef ().setName (NAME));
   key.setKeys (property_refs);

   SimpleProperty name = new SimpleProperty ();
   name.setName (NAME);
   name.setType (EdmSimpleTypeKind.String);
   name.setFacets (new Facets ().setNullable (false));
   name.setCustomizableFeedMappings (new CustomizableFeedMappings ()
         .setFcTargetPath (EdmTargetPath.SYNDICATION_TITLE));

   SimpleProperty description = new SimpleProperty ();
   description.setName (DESCRIPTION);
   description.setType (EdmSimpleTypeKind.String);
   description.setFacets (new Facets ().setNullable (false));

   List<Property> properties = new ArrayList<> ();
   properties.add (name);
   properties.add (description);

   EntityType entityType = new EntityType ();
   entityType.setName (ENTITY_NAME);
   entityType.setProperties (properties);
   entityType.setKey (key);

   return entityType;
}
 
Example #9
Source File: ClassEntitySet.java    From DataHubSystem with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public EntityType getEntityType ()
{
   List<Property> properties = new ArrayList<Property> ();
   properties.add (new SimpleProperty ()
   .setName (ID)
   .setType (EdmSimpleTypeKind.String)
   .setFacets (new Facets ().setNullable (false))
   .setCustomizableFeedMappings (
      new CustomizableFeedMappings ()
         .setFcTargetPath (EdmTargetPath.SYNDICATION_TITLE)));
   
   properties.add (new SimpleProperty ().setName (URI).setType (
      EdmSimpleTypeKind.String));
  
   // Navigation Properties
   List<NavigationProperty> navigationProperties =
      new ArrayList<NavigationProperty> ();
   // TODO (OData v3) setContainsTarget(true)
   navigationProperties.add (new NavigationProperty ().setName (getName ())
      .setRelationship (ASSO_CLASS_CLASS).setFromRole (ROLE_CLASS_PARENT)
      .setToRole (ROLE_CLASS_CLASSES));

   // Key
   Key key =
      new Key ().setKeys (Collections.singletonList (new PropertyRef ()
         .setName (ID)));

   return new EntityType ().setName (ENTITY_NAME).setProperties (properties)
      .setKey (key).setNavigationProperties (navigationProperties);
}
 
Example #10
Source File: CollectionEntitySet.java    From DataHubSystem with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public EntityType getEntityType ()
{
   List<Property> properties = new ArrayList<>();
   properties.add (new SimpleProperty ()
      .setName (NAME)
      .setType (EdmSimpleTypeKind.String)
      .setFacets (new Facets ().setNullable (false))
      .setCustomizableFeedMappings (
         new CustomizableFeedMappings ()
            .setFcTargetPath (EdmTargetPath.SYNDICATION_TITLE)));
   properties.add (new SimpleProperty ().setName (DESCRIPTION).setType (
      EdmSimpleTypeKind.String));

   // Navigation Properties
   List<NavigationProperty> navigationProperties =
      Collections.singletonList(new NavigationProperty()
         .setName(Model.PRODUCT.getName())
         .setRelationship(ASSO_COLLECTION_PRODUCT)
         .setFromRole(ROLE_PRODUCT_COLLECTIONS)
         .setToRole(ROLE_COLLECTION_PRODUCTS));

   // Key
   Key key =
      new Key ().setKeys (Collections.singletonList (new PropertyRef ()
         .setName (NAME)));

   return new EntityType ().setName (ENTITY_NAME).setProperties (properties)
      .setKey (key).setNavigationProperties (navigationProperties);
}
 
Example #11
Source File: AttributeEntitySet.java    From DataHubSystem with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public EntityType getEntityType ()
{
   EntityType res = Model.ITEM.getEntityType();

   List<Property> properties = res.getProperties ();
   properties.add ((Property) new SimpleProperty ().setName (VALUE)
         .setType (EdmSimpleTypeKind.String));
   properties.add((Property) new SimpleProperty().setName(CATEGORY)
         .setType(EdmSimpleTypeKind.String)
         .setFacets(new Facets().setDefaultValue(null)));

   return res.setName (ENTITY_NAME).setProperties (properties);
}
 
Example #12
Source File: NetworkStatisticEntitySet.java    From DataHubSystem with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public EntityType getEntityType ()
{
   // Properties
   List<Property> properties = new ArrayList<Property> ();

   properties.add (new SimpleProperty ()
   .setName (ID)
   .setType (EdmSimpleTypeKind.Int64)
   .setFacets (new Facets ().setNullable (false))
   .setCustomizableFeedMappings (
      new CustomizableFeedMappings ()
         .setFcTargetPath (EdmTargetPath.SYNDICATION_TITLE)));

   properties.add (new SimpleProperty ()
      .setName (ACTIVITYPERIOD)
      .setType (EdmSimpleTypeKind.Int64));

   properties.add (new SimpleProperty ()
      .setName (CONNECTIONNUMBER)
      .setType (EdmSimpleTypeKind.Int64));
   // Key
   Key key =
      new Key ().setKeys (Collections.singletonList (new PropertyRef ()
         .setName (ID)));

   return new EntityType ().setName (ENTITY_NAME).setProperties (properties)
      .setKey (key);
}
 
Example #13
Source File: NetworkEntitySet.java    From DataHubSystem with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public EntityType getEntityType ()
{
   // Properties
   List<Property> properties = new ArrayList<Property> ();

   properties.add (new SimpleProperty ()
   .setName (ID)
   .setType (EdmSimpleTypeKind.Int64)
   .setFacets (new Facets ().setNullable (false))
   .setCustomizableFeedMappings (
      new CustomizableFeedMappings ()
         .setFcTargetPath (EdmTargetPath.SYNDICATION_TITLE)));

   // Key
   Key key =
      new Key ().setKeys (Collections.singletonList (new PropertyRef ()
         .setName (ID)));

   // Navigation Properties
   List<NavigationProperty> navigationProperties =
      new ArrayList<NavigationProperty> ();

   if (Security.currentUserHasRole(Role.STATISTICS))
   {
      navigationProperties.add (new NavigationProperty ()
         .setName ("NetworkStatistic")
         .setRelationship (ASSO_NETWORK_NETWORKSTATISTIC)
         .setFromRole (ROLE_NETWORKSTATISTIC_NETWORK)
         .setToRole (ROLE_NETWORK_NETWORKSTATISTIC));
   }

   return new EntityType ().setName (ENTITY_NAME).setProperties (properties)
      .setKey (key).setNavigationProperties (navigationProperties);
}
 
Example #14
Source File: RestrictionEntitySet.java    From DataHubSystem with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public EntityType getEntityType ()
{
   List<Property> properties = new ArrayList<> ();

   SimpleProperty uuid = new SimpleProperty ();
   uuid.setName (UUID);
   uuid.setType (EdmSimpleTypeKind.String);
   uuid.setFacets (new Facets ().setNullable (false));
   uuid.setCustomizableFeedMappings (new CustomizableFeedMappings ()
         .setFcTargetPath (EdmTargetPath.SYNDICATION_TITLE));
   properties.add (uuid);

   SimpleProperty restriction_type = new SimpleProperty ();
   restriction_type.setName (RESTRICTION_TYPE);
   restriction_type.setType (EdmSimpleTypeKind.String);
   restriction_type.setFacets (new Facets ().setNullable (false));
   properties.add (restriction_type);

   SimpleProperty reason = new SimpleProperty ();
   reason.setName (REASON);
   reason.setType (EdmSimpleTypeKind.String);
   reason.setFacets (new Facets ().setNullable (false));
   properties.add (reason);

   Key key = new Key ();
   List<PropertyRef> propertyRefs = Collections.singletonList (
         new PropertyRef ().setName (UUID));
   key.setKeys (propertyRefs);

   EntityType entityType = new EntityType ();
   entityType.setName (ENTITY_NAME);
   entityType.setProperties (properties);
   entityType.setKey (key);

   return entityType;
}
 
Example #15
Source File: XmlMetadataDeserializer.java    From olingo-odata2 with Apache License 2.0 4 votes vote down vote up
private EdmFacets readFacets(final XMLStreamReader reader) throws XMLStreamException {
  String isNullable = reader.getAttributeValue(null, XmlMetadataConstants.EDM_PROPERTY_NULLABLE);
  String maxLength = reader.getAttributeValue(null, XmlMetadataConstants.EDM_PROPERTY_MAX_LENGTH);
  String precision = reader.getAttributeValue(null, XmlMetadataConstants.EDM_PROPERTY_PRECISION);
  String scale = reader.getAttributeValue(null, XmlMetadataConstants.EDM_PROPERTY_SCALE);
  String isFixedLength = reader.getAttributeValue(null, XmlMetadataConstants.EDM_PROPERTY_FIXED_LENGTH);
  String isUnicode = reader.getAttributeValue(null, XmlMetadataConstants.EDM_PROPERTY_UNICODE);
  String concurrencyMode = reader.getAttributeValue(null, XmlMetadataConstants.EDM_PROPERTY_CONCURRENCY_MODE);
  String defaultValue = reader.getAttributeValue(null, XmlMetadataConstants.EDM_PROPERTY_DEFAULT_VALUE);
  String collation = reader.getAttributeValue(null, XmlMetadataConstants.EDM_PROPERTY_COLLATION);
  if (isNullable != null || maxLength != null || precision != null || scale != null || isFixedLength != null
      || isUnicode != null || concurrencyMode != null || defaultValue != null || collation != null) {
    EdmFacets facets = new Facets();
    if (isNullable != null) {
      ((Facets) facets).setNullable("true".equalsIgnoreCase(isNullable));
    }
    if (maxLength != null) {
      if (XmlMetadataConstants.EDM_PROPERTY_MAX_LENGTH_MAX_VALUE_FIRST_UPPERCASE.equals(maxLength)
          || XmlMetadataConstants.EDM_PROPERTY_MAX_LENGTH_MAX_VALUE_LOWERCASE.equals(maxLength)) {
        ((Facets) facets).setMaxLength(Integer.MAX_VALUE);
      } else {
        ((Facets) facets).setMaxLength(Integer.parseInt(maxLength));
      }
    }
    if (precision != null) {
      ((Facets) facets).setPrecision(Integer.parseInt(precision));
    }
    if (scale != null) {
      ((Facets) facets).setScale(Integer.parseInt(scale));
    }
    if (isFixedLength != null) {
      ((Facets) facets).setFixedLength("true".equalsIgnoreCase(isFixedLength));
    }
    if (isUnicode != null) {
      ((Facets) facets).setUnicode("true".equalsIgnoreCase(isUnicode));
    }
    for (int i = 0; i < EdmConcurrencyMode.values().length; i++) {
      if (EdmConcurrencyMode.values()[i].name().equalsIgnoreCase(concurrencyMode)) {
        ((Facets) facets).setConcurrencyMode(EdmConcurrencyMode.values()[i]);
      }
    }
    ((Facets) facets).setDefaultValue(defaultValue);
    ((Facets) facets).setCollation(collation);
    return facets;
  } else {
    return null;
  }
}
 
Example #16
Source File: UserSynchronizerEntitySet.java    From DataHubSystem with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public EntityType getEntityType()
{
   List<Property> properties = new ArrayList<>();

   properties.add(new SimpleProperty().setName(ID)
         .setType(EdmSimpleTypeKind.Int64)
         .setFacets(new Facets().setNullable(false))
         .setCustomizableFeedMappings(
               new CustomizableFeedMappings().setFcTargetPath(EdmTargetPath.SYNDICATION_TITLE)));

   properties.add(new SimpleProperty().setName(LABEL)
         .setType(EdmSimpleTypeKind.String));

   properties.add(new SimpleProperty().setName(CREATION_DATE)
         .setType(EdmSimpleTypeKind.DateTime)
         .setFacets(new Facets().setNullable(false)));

   properties.add(new SimpleProperty().setName(MODIFICATION_DATE)
         .setType(EdmSimpleTypeKind.DateTime)
         .setFacets(new Facets().setNullable(false))
         .setCustomizableFeedMappings(
               new CustomizableFeedMappings().setFcTargetPath(EdmTargetPath.SYNDICATION_UPDATED)));

   properties.add(new SimpleProperty().setName(REQUEST)
         .setType(EdmSimpleTypeKind.String)
         .setFacets(
            new Facets()
               .setNullable(false)
               .setDefaultValue("stop")
         )
   );

   properties.add(new SimpleProperty().setName(SCHEDULE)
         .setType(EdmSimpleTypeKind.String)
         .setFacets(new Facets().setNullable(false)));

   properties.add(new SimpleProperty().setName(STATUS)
         .setType(EdmSimpleTypeKind.String)
         .setFacets(new Facets().setNullable(false)));

   properties.add(new SimpleProperty().setName(STATUS_DATE)
         .setType(EdmSimpleTypeKind.DateTime));

   properties.add(new SimpleProperty().setName(STATUS_MESSAGE)
         .setType(EdmSimpleTypeKind.String));

   properties.add(new SimpleProperty().setName(SERVICE_URL)
         .setType(EdmSimpleTypeKind.String)
         .setFacets(new Facets().setNullable(false)));

   properties.add(new SimpleProperty().setName(SERVICE_LOGIN)
         .setType(EdmSimpleTypeKind.String));

   properties.add(new SimpleProperty().setName(SERVICE_PASSWORD)
         .setType(EdmSimpleTypeKind.String));

   properties.add(new SimpleProperty().setName(CURSOR)
         .setType(EdmSimpleTypeKind.Int64)
         .setFacets(
               new Facets()
                     .setNullable(false)
                     .setDefaultValue("0")
         )
   );

   properties.add(new SimpleProperty().setName(PAGE_SIZE)
         .setType(EdmSimpleTypeKind.Int64)
         .setFacets(
               new Facets()
                     .setNullable(false)
                     .setDefaultValue("500")
         )
   );

   properties.add(new SimpleProperty().setName(FORCE)
         .setType(EdmSimpleTypeKind.Boolean)
         .setFacets(
               new Facets()
                     .setDefaultValue("false")
         )
   );

   // Key
   Key key = new Key().setKeys(Collections.singletonList(new PropertyRef().setName(ID)));

   return new EntityType().setName(ENTITY_NAME).setProperties(properties).setKey(key);
}
 
Example #17
Source File: ScenarioEdmProvider.java    From olingo-odata2 with Apache License 2.0 4 votes vote down vote up
@Override
public FunctionImport getFunctionImport(final String entityContainer, final String name) throws ODataException {
  if (ENTITY_CONTAINER_1.equals(entityContainer)) {
    if (FUNCTION_IMPORT_1.equals(name)) {
      return new FunctionImport().setName(name)
          .setReturnType(new ReturnType().setTypeName(ENTITY_TYPE_1_1).setMultiplicity(EdmMultiplicity.MANY))
          .setEntitySet(ENTITY_SET_1_1)
          .setHttpMethod("GET")
          .setParameters(Arrays.asList(
              new FunctionImportParameter().setName("q").setType(EdmSimpleTypeKind.String)
                  .setFacets(new Facets().setNullable(true))));

    } else if (FUNCTION_IMPORT_2.equals(name)) {
      return new FunctionImport().setName(name)
          .setReturnType(new ReturnType().setTypeName(COMPLEX_TYPE_1).setMultiplicity(EdmMultiplicity.MANY))
          .setHttpMethod("GET");

    } else if (FUNCTION_IMPORT_3.equals(name)) {
      return new FunctionImport().setName(name)
          .setReturnType(
              new ReturnType().setTypeName(EdmSimpleTypeKind.String.getFullQualifiedName()).setMultiplicity(
                  EdmMultiplicity.MANY))
          .setHttpMethod("GET");

    } else if (FUNCTION_IMPORT_4.equals(name)) {
      return new FunctionImport().setName(name)
          .setReturnType(
              new ReturnType().setTypeName(EdmSimpleTypeKind.Int16.getFullQualifiedName()).setMultiplicity(
                  EdmMultiplicity.ONE))
          .setHttpMethod("GET");

    } else if (FUNCTION_IMPORT_5.equals(name)) {
      return new FunctionImport().setName(name)
          .setReturnType(new ReturnType().setTypeName(COMPLEX_TYPE_1).setMultiplicity(EdmMultiplicity.ONE))
          .setHttpMethod("GET");

    } else if (FUNCTION_IMPORT_6.equals(name)) {
      return new FunctionImport().setName(name)
          .setReturnType(
              new ReturnType().setTypeName(EdmSimpleTypeKind.Binary.getFullQualifiedName()).setMultiplicity(
                  EdmMultiplicity.ONE))
          .setHttpMethod("GET")
          .setParameters(Arrays.asList(
              new FunctionImportParameter().setName("Id").setType(EdmSimpleTypeKind.String)
                  .setFacets(new Facets().setNullable(false))));

    } else if (FUNCTION_IMPORT_7.equals(name)) {
      return new FunctionImport().setName(name)
          .setReturnType(new ReturnType().setTypeName(ENTITY_TYPE_1_1).setMultiplicity(EdmMultiplicity.ZERO_TO_ONE))
          .setEntitySet(ENTITY_SET_1_1)
          .setHttpMethod("GET");
    } else if (ACTION_IMPORT_1.equals(name)) {
      return new FunctionImport().setName(name)
          .setEntitySet(ENTITY_SET_1_1)
          .setHttpMethod("POST")/*.setParameters(Arrays.asList(
              new FunctionImportParameter().setName("Id").setType(EdmSimpleTypeKind.String)
              .setFacets(new Facets().setNullable(false))))*/;
    }
  }

  return null;
}
 
Example #18
Source File: XmlMetadataConsumer.java    From olingo-odata2 with Apache License 2.0 4 votes vote down vote up
private Facets readFacets(final XMLStreamReader reader) throws XMLStreamException {
  String isNullable = reader.getAttributeValue(null, XmlMetadataConstants.EDM_PROPERTY_NULLABLE);
  String maxLength = reader.getAttributeValue(null, XmlMetadataConstants.EDM_PROPERTY_MAX_LENGTH);
  String precision = reader.getAttributeValue(null, XmlMetadataConstants.EDM_PROPERTY_PRECISION);
  String scale = reader.getAttributeValue(null, XmlMetadataConstants.EDM_PROPERTY_SCALE);
  String isFixedLength = reader.getAttributeValue(null, XmlMetadataConstants.EDM_PROPERTY_FIXED_LENGTH);
  String isUnicode = reader.getAttributeValue(null, XmlMetadataConstants.EDM_PROPERTY_UNICODE);
  String concurrencyMode = reader.getAttributeValue(null, XmlMetadataConstants.EDM_PROPERTY_CONCURRENCY_MODE);
  String defaultValue = reader.getAttributeValue(null, XmlMetadataConstants.EDM_PROPERTY_DEFAULT_VALUE);
  String collation = reader.getAttributeValue(null, XmlMetadataConstants.EDM_PROPERTY_COLLATION);
  if (isNullable != null || maxLength != null || precision != null || scale != null || isFixedLength != null
      || isUnicode != null || concurrencyMode != null || defaultValue != null || collation != null) {
    Facets facets = new Facets();
    if (isNullable != null) {
      facets.setNullable("true".equalsIgnoreCase(isNullable));
    }
    if (maxLength != null) {
      if (XmlMetadataConstants.EDM_PROPERTY_MAX_LENGTH_MAX_VALUE_FIRST_UPPERCASE.equals(maxLength)
          || XmlMetadataConstants.EDM_PROPERTY_MAX_LENGTH_MAX_VALUE_LOWERCASE.equals(maxLength)) {
        facets.setMaxLength(Integer.MAX_VALUE);
      } else {
        facets.setMaxLength(Integer.parseInt(maxLength));
      }
    }
    if (precision != null) {
      facets.setPrecision(Integer.parseInt(precision));
    }
    if (scale != null) {
      facets.setScale(Integer.parseInt(scale));
    }
    if (isFixedLength != null) {
      facets.setFixedLength("true".equalsIgnoreCase(isFixedLength));
    }
    if (isUnicode != null) {
      facets.setUnicode("true".equalsIgnoreCase(isUnicode));
    }
    for (int i = 0; i < EdmConcurrencyMode.values().length; i++) {
      if (EdmConcurrencyMode.values()[i].name().equalsIgnoreCase(concurrencyMode)) {
        facets.setConcurrencyMode(EdmConcurrencyMode.values()[i]);
      }
    }
    facets.setDefaultValue(defaultValue);
    facets.setCollation(collation);
    return facets;
  } else {
    return null;
  }
}
 
Example #19
Source File: SynchronizerEntitySet.java    From DataHubSystem with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public EntityType getEntityType ()
{
   List<Property> properties = new ArrayList<> ();
   properties.add (new SimpleProperty ().setName (ID)
         .setType (EdmSimpleTypeKind.Int64)
         .setFacets (new Facets ().setNullable (false)));

   properties.add (new SimpleProperty ().setName (LABEL)
         .setType (EdmSimpleTypeKind.String));

   properties.add (new SimpleProperty ().setName (CREATION_DATE)
         .setType (EdmSimpleTypeKind.DateTime)
         .setFacets (new Facets ().setNullable (false)));

   properties.add (new SimpleProperty ().setName (MODIFICATION_DATE)
         .setType (EdmSimpleTypeKind.DateTime)
         .setFacets (new Facets ().setNullable (false)));

   properties.add (new SimpleProperty ().setName (SERVICE_URL)
         .setType (EdmSimpleTypeKind.String)
         .setFacets (new Facets ().setNullable (false)));

   properties.add (new SimpleProperty ().setName (SERVICE_LOGIN)
         .setType (EdmSimpleTypeKind.String));

   properties.add (new SimpleProperty ().setName (SERVICE_PASSWORD)
         .setType (EdmSimpleTypeKind.String));

   properties.add (new SimpleProperty ().setName (REMOTE_INCOMING)
         .setType (EdmSimpleTypeKind.String));

   properties.add (new SimpleProperty ().setName (SCHEDULE)
         .setType (EdmSimpleTypeKind.String)
         .setFacets (new Facets ().setNullable (false)));

   properties.add (new SimpleProperty ().setName (PAGE_SIZE)
         .setType (EdmSimpleTypeKind.Int32)
         .setFacets (
               new Facets ()
                     .setNullable (false)
                     .setDefaultValue ("30")
         )
   );

   properties.add(new SimpleProperty ().setName(COPY_PRODUCT)
         .setType (EdmSimpleTypeKind.Boolean)
         .setFacets (
               new Facets ()
                  .setNullable (false)
                  .setDefaultValue ("false")
         )
   );

   properties.add (new SimpleProperty ().setName (FILTER_PARAM)
         .setType (EdmSimpleTypeKind.String));

   properties.add (new SimpleProperty ().setName (SOURCE_COLLECTION)
         .setType (EdmSimpleTypeKind.String));

   properties.add (new SimpleProperty ().setName (LAST_INGESTION_DATE)
         .setType (EdmSimpleTypeKind.DateTime));

   properties.add (new SimpleProperty ().setName (REQUEST)
         .setType (EdmSimpleTypeKind.String)
         .setFacets (
            new Facets ()
               .setNullable (false)
               .setDefaultValue ("stop")
         )
   );

   properties.add (new SimpleProperty ().setName (STATUS)
         .setType (EdmSimpleTypeKind.String)
         .setFacets (new Facets ().setNullable (false)));

   properties.add (new SimpleProperty ().setName (STATUS_DATE)
         .setType (EdmSimpleTypeKind.DateTime));

   properties.add (new SimpleProperty ().setName (STATUS_MESSAGE)
         .setType (EdmSimpleTypeKind.String));

   // Navigation Properties
   List<NavigationProperty> navigationProperties = Collections.singletonList (
      new NavigationProperty ()
         .setName (TARGET_COLLECTION)
         .setRelationship (ASSO_SYNC_COLLECTION)
         .setFromRole (ROLE_COLLECTION_SYNCS)
         .setToRole (ROLE_SYNC_COLLECTION)
   );

   // Key
   Key key = new Key ().setKeys (
         Collections.singletonList (new PropertyRef ().setName (ID)));

   return new EntityType ().setName (ENTITY_NAME).setProperties (properties)
         .setNavigationProperties (navigationProperties).setKey (key);
}
 
Example #20
Source File: JPAEdmFacets.java    From olingo-odata2 with Apache License 2.0 4 votes vote down vote up
private static void setScale(final Column column, final SimpleProperty edmProperty) {
  if (column.scale() > 0) {
    ((Facets) edmProperty.getFacets()).setScale(column.scale());
  }
}
 
Example #21
Source File: JPAEdmFacets.java    From olingo-odata2 with Apache License 2.0 4 votes vote down vote up
private static void setPrecision(final Column column, final SimpleProperty edmProperty) {
  if (column.precision() > 0) {
    ((Facets) edmProperty.getFacets()).setPrecision(column.precision());
  }
}
 
Example #22
Source File: JPAEdmFacets.java    From olingo-odata2 with Apache License 2.0 4 votes vote down vote up
private static void setMaxLength(final Column column, final SimpleProperty edmProperty) {
  if (column.length() > 0) {
    ((Facets) edmProperty.getFacets()).setMaxLength(column.length());
  }
}
 
Example #23
Source File: JPAEdmFacets.java    From olingo-odata2 with Apache License 2.0 4 votes vote down vote up
private static void setNullable(final Column column, final SimpleProperty edmProperty) {
  ((Facets) edmProperty.getFacets()).setNullable(column.nullable());
}
 
Example #24
Source File: JPAEdmFacets.java    From olingo-odata2 with Apache License 2.0 4 votes vote down vote up
/**
 * Create and set new facets for SimpleProperty.
 * The new created and set facets are returned for further modification.
 *
 * @param jpaAttribute
 * @param edmProperty property at which facets are set
 * @return set new facets for SimpleProperty
 */
public static Facets createAndSet(final Attribute<?, ?> jpaAttribute, final SimpleProperty edmProperty) {
  EdmSimpleTypeKind edmTypeKind = edmProperty.getType();
  Facets facets = new Facets();
  edmProperty.setFacets(facets);

  Column column = null;
  if (jpaAttribute.getJavaMember() instanceof AnnotatedElement) {
    column = ((AnnotatedElement) jpaAttribute.getJavaMember()).getAnnotation(Column.class);
  }

  if (column == null) {
    return facets;
  }

  setNullable(column, edmProperty);

  switch (edmTypeKind) {
  case Binary:
    setMaxLength(column, edmProperty);
    break;
  case DateTime:
    setPrecision(column, edmProperty);
    break;
  case DateTimeOffset:
    setPrecision(column, edmProperty);
    break;
  case Time:
    setPrecision(column, edmProperty);
    break;
  case Decimal:
    setPrecision(column, edmProperty);
    setScale(column, edmProperty);
    break;
  case String:
    setMaxLength(column, edmProperty);
    break;
  default:
    break;
  }
  return facets;
}
 
Example #25
Source File: UserEntitySet.java    From DataHubSystem with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public EntityType getEntityType ()
{
   // Properties
   List<Property> properties = new ArrayList<Property> ();

   properties.add (new SimpleProperty ()
      .setName (USERNAME)
      .setType (EdmSimpleTypeKind.String)
      .setFacets (new Facets ().setNullable (false))
      .setCustomizableFeedMappings (
         new CustomizableFeedMappings ()
            .setFcTargetPath (EdmTargetPath.SYNDICATION_TITLE)));

   properties.add (new SimpleProperty ().setName (EMAIL).setType (
      EdmSimpleTypeKind.String));
   properties.add (new SimpleProperty ().setName (FIRSTNAME).setType (
      EdmSimpleTypeKind.String));
   properties.add (new SimpleProperty ().setName (LASTNAME).setType (
      EdmSimpleTypeKind.String));
   properties.add (new SimpleProperty ().setName (COUNTRY).setType (
      EdmSimpleTypeKind.String));
   properties.add (new SimpleProperty ().setName (PHONE).setType (
      EdmSimpleTypeKind.String));
   properties.add (new SimpleProperty ().setName (ADDRESS).setType (
      EdmSimpleTypeKind.String));
   properties.add (new SimpleProperty ().setName (DOMAIN).setType (
      EdmSimpleTypeKind.String));
   properties.add (new SimpleProperty ().setName (SUBDOMAIN).setType (
      EdmSimpleTypeKind.String));
   properties.add (new SimpleProperty ().setName (USAGE).setType (
      EdmSimpleTypeKind.String));
   properties.add (new SimpleProperty ().setName (SUBUSAGE).setType (
      EdmSimpleTypeKind.String));
   properties.add(new SimpleProperty().setName(HASH)
         .setType(EdmSimpleTypeKind.String));
   properties.add(new SimpleProperty().setName(PASSWORD)
         .setType(EdmSimpleTypeKind.String));
   properties.add(new SimpleProperty().setName(CREATED)
         .setType(EdmSimpleTypeKind.DateTime)
         .setCustomizableFeedMappings(new CustomizableFeedMappings()
               .setFcTargetPath(EdmTargetPath.SYNDICATION_UPDATED)));

   // Navigation Properties
   List<NavigationProperty> navigationProperties =
      new ArrayList<NavigationProperty> ();

   if (Security.currentUserHasRole(Role.SYSTEM_MANAGER, Role.STATISTICS))
   {
      navigationProperties.add (new NavigationProperty ()
         .setName(Model.CONNECTION.getName())
         .setRelationship(ASSO_USER_CONNECTION)
         .setFromRole(ROLE_CONNECTION_USER)
         .setToRole(ROLE_USER_CONNECTIONS));
   }

   // navigate to user restrictions
   navigationProperties.add (new NavigationProperty ()
         .setName(Model.RESTRICTION.getName())
         .setRelationship (ASSO_USER_RESTRICTION)
         .setFromRole (ROLE_RESTRICTION_USER)
         .setToRole (ROLE_USER_RESTRICTIONS));

   // navigate to user roles
   navigationProperties.add (new NavigationProperty ()
         .setName(Model.SYSTEM_ROLE.getName())
         .setRelationship (ASSO_USER_SYSTEMROLE)
         .setFromRole (ROLE_SYSTEMROLE_USER)
         .setToRole (ROLE_USER_SYSTEMROLES));

   // navigate to Products (user cart)
   navigationProperties.add(new NavigationProperty()
         .setName(CART)
         .setRelationship(ASSO_USER_PRODUCT)
         .setFromRole(ROLE_PRODUCTS_USER)
         .setToRole(ROLE_USER_PRODUCTS));

   // Key
   Key key =
      new Key ().setKeys (Collections.singletonList (new PropertyRef ()
         .setName (USERNAME)));

   return new EntityType ().setName (ENTITY_NAME).setProperties (properties)
      .setKey (key).setNavigationProperties (navigationProperties);
}
 
Example #26
Source File: JPAEdmFunctionImport.java    From olingo-odata2 with Apache License 2.0 4 votes vote down vote up
private void buildEdmParameter(final FunctionImport functionImport, final Method method)
    throws ODataJPAModelException {
  Annotation[][] annotations = method.getParameterAnnotations();
  Class<?>[] parameterTypes = method.getParameterTypes();
  List<FunctionImportParameter> funcImpList = new ArrayList<FunctionImportParameter>();
  JPAEdmMapping mapping = null;
  int j = 0;
  for (Annotation[] annotationArr : annotations) {
    Class<?> parameterType = parameterTypes[j++];

    for (Annotation element : annotationArr) {
      if (element instanceof EdmFunctionImportParameter) {
        EdmFunctionImportParameter annotation = (EdmFunctionImportParameter) element;
        FunctionImportParameter functionImportParameter = new FunctionImportParameter();
        if ("".equals(annotation.name())) {
          throw ODataJPAModelException.throwException(ODataJPAModelException.FUNC_PARAM_NAME_EXP.addContent(method
              .getDeclaringClass().getName(), method.getName()), null);
        } else {
          functionImportParameter.setName(annotation.name());
        }

        functionImportParameter.setType(JPATypeConverter.convertToEdmSimpleType(parameterType, null));

        Facets facets = new Facets();
        if (annotation.facets().maxLength() > 0) {
          facets.setMaxLength(annotation.facets().maxLength());
        }
        if (annotation.facets().nullable() == false) {
          facets.setNullable(false);
        } else {
          facets.setNullable(true);
        }

        if (annotation.facets().precision() > 0) {
          facets.setPrecision(annotation.facets().precision());
        }
        if (annotation.facets().scale() >= 0) {
          facets.setScale(annotation.facets().scale());
        }

        functionImportParameter.setFacets(facets);
        mapping = new JPAEdmMappingImpl();
        mapping.setJPAType(parameterType);
        functionImportParameter.setMapping((Mapping) mapping);
        funcImpList.add(functionImportParameter);
      }
    }
  }
  if (!funcImpList.isEmpty()) {
    functionImport.setParameters(funcImpList);
  }
}
 
Example #27
Source File: ProductEntitySet.java    From DataHubSystem with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public EntityType getEntityType ()
{
   EntityType res = Model.NODE.getEntityType();

   // Properties
   List<Property> properties = res.getProperties ();

   properties.add (new SimpleProperty ().setName (CREATION_DATE)
      .setType (EdmSimpleTypeKind.DateTime)
      .setFacets (new Facets ().setNullable (false)));
   properties.add (new SimpleProperty ()
      .setName (INGESTION_DATE)
      .setType (EdmSimpleTypeKind.DateTime)
      .setCustomizableFeedMappings (
         new CustomizableFeedMappings ()
            .setFcTargetPath (EdmTargetPath.SYNDICATION_UPDATED)));
   properties.add (new SimpleProperty ().setName (EVICTION_DATE).setType (
      EdmSimpleTypeKind.DateTime));
   properties.add(new ComplexProperty().setName(CONTENT_DATE).setType(Model.TIME_RANGE));
   properties.add(new ComplexProperty().setName(CHECKSUM).setType(Model.CHECKSUM));
   properties.add (new SimpleProperty ().setName (CONTENT_GEOMETRY).setType (
      EdmSimpleTypeKind.String));
   properties.add (new SimpleProperty ().setName (METALINK).setType (
      EdmSimpleTypeKind.String));

   if (Security.currentUserHasRole(Role.ARCHIVE_MANAGER))
   {
      properties.add (new SimpleProperty ().setName (LOCAL_PATH).setType (
         EdmSimpleTypeKind.String));
   }

   // Navigation Properties
   List<NavigationProperty> navigationProperties =
      new ArrayList<NavigationProperty> ();

   navigationProperties.add (new NavigationProperty ().setName (getName ())
      .setRelationship (ASSO_PRODUCT_PRODUCT)
      .setFromRole (ROLE_PRODUCT_PRODUCT).setToRole (ROLE_PRODUCT_PRODUCTS));
   navigationProperties.add (new NavigationProperty ()
      .setName(Model.NODE.getName()).setRelationship(ASSO_PRODUCT_NODE)
      .setFromRole (ROLE_NODE_PRODUCT).setToRole (ROLE_PRODUCT_NODES));
   navigationProperties.add (new NavigationProperty ()
      .setName(Model.ATTRIBUTE.getName())
      .setRelationship (ASSO_PRODUCT_ATTRIBUTE)
      .setFromRole (ROLE_ATTRIBUTE_PRODUCT)
      .setToRole (ROLE_PRODUCT_ATTRIBUTES));
   navigationProperties.add (new NavigationProperty ().setName ("Class")
      .setRelationship (ASSO_PRODUCT_CLASS)
      .setFromRole (ROLE_CLASS_PRODUCTS).setToRole (ROLE_PRODUCT_CLASS));

   // TODO (OData v3) setContainsTarget(true) setBaseType(ENTITY_ITEM)
   return res.setName (ENTITY_NAME).setProperties (properties)
      .setHasStream (true).setNavigationProperties (navigationProperties);
}
 
Example #28
Source File: ConnectionEntitySet.java    From DataHubSystem with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public EntityType getEntityType ()
{
   // Properties
   List<Property> properties = new ArrayList<Property> ();

   properties.add (new SimpleProperty ()
      .setName (ID)
      .setType (EdmSimpleTypeKind.String)
      .setFacets (new Facets ().setNullable (false))
      .setCustomizableFeedMappings (
         new CustomizableFeedMappings ()
            .setFcTargetPath (EdmTargetPath.SYNDICATION_TITLE)));

   properties.add (new SimpleProperty ().setName (DATE).setType (
      EdmSimpleTypeKind.DateTime));
   properties.add (new SimpleProperty ().setName (REMOTEIP).setType (
      EdmSimpleTypeKind.String));
   properties.add (new SimpleProperty ().setName (REQUEST).setType (
      EdmSimpleTypeKind.String));
   properties.add (new SimpleProperty ().setName (DURATION).setType (
      EdmSimpleTypeKind.Double));
   properties.add (new SimpleProperty ().setName (CONTENT_LENGTH).setType (
      EdmSimpleTypeKind.Int64));
   properties.add (new SimpleProperty ().setName (WRITTEN_CONTENT_LENGTH).
      setType (EdmSimpleTypeKind.Int64));
   properties.add (new SimpleProperty ().setName (STATUS).setType (
         EdmSimpleTypeKind.String));
   properties.add (new SimpleProperty ().setName (STATUS_MESSAGE).setType (
         EdmSimpleTypeKind.String).
         setFacets (new Facets ().setNullable (true)));

   // Navigation Properties
   List<NavigationProperty> navigationProperties =
      new ArrayList<NavigationProperty> ();

   if (Security.currentUserHasRole(Role.SYSTEM_MANAGER))
   {
   navigationProperties.add (new NavigationProperty ().setName ("User")
      .setRelationship (ASSO_CONNECTION_USER)
      .setFromRole (ROLE_USER_CONNECTIONS).setToRole (ROLE_CONNECTION_USER));
   }

   // Key
   Key key =
      new Key ().setKeys (Collections.singletonList (new PropertyRef ()
         .setName (ID)));

   return new EntityType ().setName (ENTITY_NAME).setProperties (properties)
      .setKey (key).setNavigationProperties (navigationProperties);
}
 
Example #29
Source File: IngestEntitySet.java    From DataHubSystem with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public EntityType getEntityType()
{
   // Properties
   List<Property> properties = new ArrayList<>();
   properties.add(new SimpleProperty().setName(ID)
         .setType(EdmSimpleTypeKind.Int64)
         .setFacets(new Facets().setNullable(false))
         .setCustomizableFeedMappings(
               new CustomizableFeedMappings().setFcTargetPath(EdmTargetPath.SYNDICATION_TITLE)));

   properties.add(new SimpleProperty().setName(STATUS)
         .setType(EdmSimpleTypeKind.String)
         .setFacets(new Facets().setNullable(false)));

   properties.add(new SimpleProperty().setName(STATUS_DATE)
         .setType(EdmSimpleTypeKind.DateTime)
         .setCustomizableFeedMappings(
               new CustomizableFeedMappings().setFcTargetPath(EdmTargetPath.SYNDICATION_UPDATED)));

   properties.add(new SimpleProperty().setName(STATUS_MESSAGE)
         .setType(EdmSimpleTypeKind.String));


   properties.add(new SimpleProperty().setName(FILENAME)
         .setType(EdmSimpleTypeKind.String));

   properties.add(new SimpleProperty().setName(MD5)
         .setType(EdmSimpleTypeKind.String)
         .setFacets(new Facets().setNullable(false)));

   // Key
   Key key = new Key().setKeys(
         Collections.singletonList(new PropertyRef().setName(ID)));

   // Navigation Properties
   List<NavigationProperty> navigationProperties = new ArrayList<>(2);
   navigationProperties.add(
         new NavigationProperty()
         .setName(TARGET_COLLECTIONS)
         .setRelationship(ASSO_INGEST_COLLECTION)
         .setToRole(ROLE_INGEST_COLLECTIONS)
         .setFromRole(ROLE_COLLECTION_INGESTS)
   );
   navigationProperties.add(
         new NavigationProperty()
         .setName(UPLOADER)
         .setRelationship(ASSO_INGEST_USER)
         .setToRole(ROLE_INGEST_USER)
         .setFromRole(ROLE_USER_INGEST)
   );

   return new EntityType()
         .setName(ENTITY_NAME)
         .setProperties(properties)
         .setKey(key)
         .setNavigationProperties(navigationProperties)
         .setHasStream(true);
}