Java Code Examples for org.apache.olingo.odata2.api.edm.provider.EntityType#setName()

The following examples show how to use org.apache.olingo.odata2.api.edm.provider.EntityType#setName() . 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: JPAEdmNameBuilder.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
public static void build(final JPAEdmEntityTypeView view) {

    EntityType edmEntityType = view.getEdmEntityType();
    String jpaEntityName = view.getJPAEntityType().getName();
    JPAEdmMappingModelAccess mappingModelAccess = view.getJPAEdmMappingModelAccess();
    String edmEntityTypeName = null;
    if (mappingModelAccess != null && mappingModelAccess.isMappingModelExists()) {
      edmEntityTypeName = mappingModelAccess.mapJPAEntityType(jpaEntityName);
    }

    JPAEdmMapping mapping = new JPAEdmMappingImpl();
    mapping.setJPAType(view.getJPAEntityType().getJavaType());

    if (edmEntityTypeName == null) {
      edmEntityTypeName = jpaEntityName;
    }
    // Setting the mapping object
    edmEntityType.setMapping(((Mapping) mapping).setInternalName(jpaEntityName));

    edmEntityType.setName(edmEntityTypeName);

  }
 
Example 2
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 3
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 4
Source File: JPAEdmAssociationEndTest.java    From olingo-odata2 with Apache License 2.0 4 votes vote down vote up
@Override
public EntityType getEdmEntityType() {
  EntityType entityType = new EntityType();
  entityType.setName(SimpleTypeA.NAME);
  return entityType;
}
 
Example 5
Source File: JPAEdmAssociationTest.java    From olingo-odata2 with Apache License 2.0 4 votes vote down vote up
@Override
public EntityType getEdmEntityType() {
  EntityType entityType = new EntityType();
  entityType.setName(SimpleTypeA.NAME);
  return entityType;
}
 
Example 6
Source File: XmlMetadataConsumer.java    From olingo-odata2 with Apache License 2.0 4 votes vote down vote up
private EntityType readEntityType(final XMLStreamReader reader) throws XMLStreamException, EntityProviderException {
  reader.require(XMLStreamConstants.START_ELEMENT, edmNamespace, XmlMetadataConstants.EDM_ENTITY_TYPE);
  EntityType entityType = new EntityType();
  List<Property> properties = new ArrayList<Property>();
  List<NavigationProperty> navPropertiesList = new ArrayList<NavigationProperty>();
  List<AnnotationElement> annotationElements = new ArrayList<AnnotationElement>();
  Key key = null;

  entityType.setName(reader.getAttributeValue(null, XmlMetadataConstants.EDM_NAME));
  String hasStream = reader.getAttributeValue(Edm.NAMESPACE_M_2007_08, XmlMetadataConstants.M_ENTITY_TYPE_HAS_STREAM);
  if (hasStream != null) {
    entityType.setHasStream("true".equalsIgnoreCase(hasStream));
  }

  if (reader.getAttributeValue(null, XmlMetadataConstants.EDM_TYPE_ABSTRACT) != null) {
    entityType.setAbstract("true".equalsIgnoreCase(reader.getAttributeValue(null,
        XmlMetadataConstants.EDM_TYPE_ABSTRACT)));
  }
  String baseType = reader.getAttributeValue(null, XmlMetadataConstants.EDM_BASE_TYPE);
  if (baseType != null) {
    entityType.setBaseType(extractFQName(baseType));
  }
  entityType.setCustomizableFeedMappings(readCustomizableFeedMappings(reader));
  entityType.setAnnotationAttributes(readAnnotationAttribute(reader));
  while (reader.hasNext()
      && !(reader.isEndElement() && edmNamespace.equals(reader.getNamespaceURI())
      && XmlMetadataConstants.EDM_ENTITY_TYPE.equals(reader.getLocalName()))) {
    reader.next();
    if (reader.isStartElement()) {
      currentHandledStartTagName = reader.getLocalName();
      if (XmlMetadataConstants.EDM_ENTITY_TYPE_KEY.equals(currentHandledStartTagName)) {
        key = readEntityTypeKey(reader);
      } else if (XmlMetadataConstants.EDM_PROPERTY.equals(currentHandledStartTagName)) {
        properties.add(readProperty(reader));
      } else if (XmlMetadataConstants.EDM_NAVIGATION_PROPERTY.equals(currentHandledStartTagName)) {
        navPropertiesList.add(readNavigationProperty(reader));
      } else {
        annotationElements.add(readAnnotationElement(reader));
      }
      extractNamespaces(reader);
    }
  }
  if (!annotationElements.isEmpty()) {
    entityType.setAnnotationElements(annotationElements);
  }
  entityType.setKey(key).setProperties(properties).setNavigationProperties(navPropertiesList);
  if (entityType.getName() != null) {
    FullQualifiedName fqName = new FullQualifiedName(currentNamespace, entityType.getName());
    entityTypesMap.put(fqName, entityType);
  } else {
    throw new EntityProviderException(EntityProviderException.MISSING_ATTRIBUTE.addContent("Name"));
  }
  return entityType;
}
 
Example 7
Source File: MapProvider.java    From olingo-odata2 with Apache License 2.0 4 votes vote down vote up
private void buildSchema() {
  propertyRef = new PropertyRef();
  propertyRef.setName("p1");

  key = new Key();
  key.setKeys(Arrays.asList(propertyRef));

  property1 =
      new SimpleProperty().setName(mapping[P1][EDM]).setType(EdmSimpleTypeKind.String).setMapping(
          new Mapping().setObject(mapping[P1][BACKEND]));
  property2 =
      new SimpleProperty().setName(mapping[P2][EDM]).setType(EdmSimpleTypeKind.String).setMapping(
          new Mapping().setObject(mapping[P2][BACKEND]));
  property3 =
      new SimpleProperty().setName(mapping[P3][EDM]).setType(EdmSimpleTypeKind.String).setMapping(
          new Mapping().setObject(mapping[P3][BACKEND]));

  entityType = new EntityType();
  entityType.setName(mapping[ENTITYTYPE][EDM]);
  entityType.setKey(key);
  entityType.setProperties(Arrays.asList(property1, property2, property3));
  entityType.setMapping(new Mapping().setObject(mapping[ENTITYTYPE][BACKEND]));

  entitySet = new EntitySet();
  entitySet.setName(mapping[ENTITYSET][EDM]);
  entitySet.setEntityType(new FullQualifiedName(NAMESPACE, mapping[ENTITYTYPE][EDM]));
  entitySet.setMapping(new Mapping().setObject(mapping[ENTITYSET][BACKEND]));

  entityContainer = new EntityContainer();
  entityContainer.setDefaultEntityContainer(true);
  entityContainer.setName(MAPPING_CONTAINER);
  entityContainer.setEntitySets(Arrays.asList(entitySet));

  schema = new Schema();
  schema.setNamespace("mapping");
  schema.setAlias(NAMESPACE);
  schema.setEntityContainers(Arrays.asList(entityContainer));
  schema.setEntityTypes(Arrays.asList(entityType));

  schemas = Arrays.asList(schema);
}