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

The following examples show how to use org.apache.olingo.odata2.api.edm.provider.CustomizableFeedMappings. 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: XmlMetadataConsumer.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
private CustomizableFeedMappings readCustomizableFeedMappings(final XMLStreamReader reader) {
  String targetPath = reader.getAttributeValue(Edm.NAMESPACE_M_2007_08, XmlMetadataConstants.M_FC_TARGET_PATH);
  String sourcePath = reader.getAttributeValue(Edm.NAMESPACE_M_2007_08, XmlMetadataConstants.M_FC_SOURCE_PATH);
  String nsUri = reader.getAttributeValue(Edm.NAMESPACE_M_2007_08, XmlMetadataConstants.M_FC_NS_URI);
  String nsPrefix = reader.getAttributeValue(Edm.NAMESPACE_M_2007_08, XmlMetadataConstants.M_FC_PREFIX);
  String keepInContent = reader.getAttributeValue(Edm.NAMESPACE_M_2007_08, XmlMetadataConstants.M_FC_KEEP_IN_CONTENT);
  String contentKind = reader.getAttributeValue(Edm.NAMESPACE_M_2007_08, XmlMetadataConstants.M_FC_CONTENT_KIND);

  if (targetPath != null || sourcePath != null || nsUri != null || nsPrefix != null || keepInContent != null
      || contentKind != null) {
    CustomizableFeedMappings feedMapping = new CustomizableFeedMappings();
    if (keepInContent != null) {
      feedMapping.setFcKeepInContent("true".equals(keepInContent));
    }
    for (int i = 0; i < EdmContentKind.values().length; i++) {
      if (EdmContentKind.values()[i].name().equalsIgnoreCase(contentKind)) {
        feedMapping.setFcContentKind(EdmContentKind.values()[i]);
      }
    }
    feedMapping.setFcTargetPath(targetPath).setFcSourcePath(sourcePath).setFcNsUri(nsUri).setFcNsPrefix(nsPrefix);
    return feedMapping;
  } else {
    return null;
  }

}
 
Example #2
Source File: EdmMappingTest.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
@BeforeClass
public static void setup() throws Exception {

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

  mappedObject = new EdmMappingTest();

  Mapping propertySimpleMapping = new Mapping().setInternalName("value").setObject(mappedObject);
  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);

  NavigationProperty navProperty =
      new NavigationProperty().setName("navProperty").setFromRole("fromRole").setToRole("toRole").setMapping(
          propertySimpleMapping);
  navPropertyProvider = new EdmNavigationPropertyImplProv(edmImplProv, navProperty);
}
 
Example #3
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 #4
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 #5
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 #6
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 #7
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 #8
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 #9
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 #10
Source File: XmlMetadataProducer.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
private static void writeCustomizableFeedMappings(final CustomizableFeedMappings customizableFeedMappings,
    final XMLStreamWriter xmlStreamWriter) throws XMLStreamException {
  if (customizableFeedMappings != null) {
    if (customizableFeedMappings.getFcKeepInContent() != null) {
      xmlStreamWriter.writeAttribute(Edm.PREFIX_M, Edm.NAMESPACE_M_2007_08,
          XmlMetadataConstants.M_FC_KEEP_IN_CONTENT, customizableFeedMappings.getFcKeepInContent().toString()
              .toLowerCase(Locale.ROOT));
    }
    if (customizableFeedMappings.getFcContentKind() != null) {
      xmlStreamWriter.writeAttribute(Edm.PREFIX_M, Edm.NAMESPACE_M_2007_08, XmlMetadataConstants.M_FC_CONTENT_KIND,
          customizableFeedMappings.getFcContentKind().toString());
    }
    if (customizableFeedMappings.getFcNsPrefix() != null) {
      xmlStreamWriter.writeAttribute(Edm.PREFIX_M, Edm.NAMESPACE_M_2007_08, XmlMetadataConstants.M_FC_PREFIX,
          customizableFeedMappings.getFcNsPrefix());
    }
    if (customizableFeedMappings.getFcNsUri() != null) {
      xmlStreamWriter.writeAttribute(Edm.PREFIX_M, Edm.NAMESPACE_M_2007_08, XmlMetadataConstants.M_FC_NS_URI,
          customizableFeedMappings.getFcNsUri());
    }
    if (customizableFeedMappings.getFcSourcePath() != null) {
      xmlStreamWriter.writeAttribute(Edm.PREFIX_M, Edm.NAMESPACE_M_2007_08, XmlMetadataConstants.M_FC_SOURCE_PATH,
          customizableFeedMappings.getFcSourcePath());
    }
    if (customizableFeedMappings.getFcTargetPath() != null) {
      xmlStreamWriter.writeAttribute(Edm.PREFIX_M, Edm.NAMESPACE_M_2007_08, XmlMetadataConstants.M_FC_TARGET_PATH,
          customizableFeedMappings.getFcTargetPath().toString());
    }
  }
}
 
Example #11
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 #12
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 #13
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 #14
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 #15
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 #16
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);
}