Package org.apache.olingo.odata2.api.edm.provider

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


            .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)
View Full Code Here


            complexTypeView.searchEdmComplexType(propertyView.getJPAAttribute().getJavaType().getName());
        normalizeComplexKey(complexType, propertyRefList);
      } else {
        PropertyRef propertyRef = new PropertyRef();
        propertyRef.setName(propertyView.getEdmSimpleProperty().getName());
        Facets facets = (Facets) propertyView.getEdmSimpleProperty().getFacets();
        if (facets == null) {
          propertyView.getEdmSimpleProperty().setFacets(new Facets().setNullable(false));
        } else {
          facets.setNullable(false);
        }
        propertyRefList.add(propertyRef);
      }

    }
View Full Code Here

    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);
View Full Code Here

import org.apache.olingo.odata2.api.edm.provider.SimpleProperty;

public class JPAEdmFacets {
  public static void setFacets(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
View Full Code Here

              functionImportParameter.setName(annotation.name());
            }

            functionImportParameter.setType(JPATypeConvertor.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);
View Full Code Here

    if (NAMESPACE_1.equals(edmFQName.getNamespace())) {
      if (ET_KEY_IS_STRING.getName().equals(edmFQName.getName())) {
        final List<Property> properties = new ArrayList<Property>();
        properties.add(new SimpleProperty().setName("KeyString")
            .setType(EdmSimpleTypeKind.String)
            .setFacets(new Facets().setNullable(false)));

        final List<NavigationProperty> navigationProperties = new ArrayList<NavigationProperty>();

        navigationProperties.add(new NavigationProperty().setName("navProperty").setFromRole(ROLE_1).setToRole(ROLE_2)
            .setRelationship(ASSOCIATION_ET1_ET2));

        return new EntityType().setName(ET_KEY_IS_STRING.getName()).setProperties(properties).setNavigationProperties(
            navigationProperties).setKey(createKey("KeyString"));
      } else if (ET_KEY_IS_INTEGER.getName().equals(edmFQName.getName())) {
        final List<Property> properties = new ArrayList<Property>();
        properties.add(new SimpleProperty().setName("KeyInteger")
            .setType(EdmSimpleTypeKind.String)
            .setFacets(new Facets().setNullable(false)));

        final List<NavigationProperty> navigationProperties = new ArrayList<NavigationProperty>();
        navigationProperties.add(new NavigationProperty().setName("navProperty").setFromRole(ROLE_2).setToRole(ROLE_1)
            .setRelationship(ASSOCIATION_ET1_ET2));

        return new EntityType().setName(ET_KEY_IS_INTEGER.getName()).setProperties(properties).setNavigationProperties(
            navigationProperties).setKey(createKey("KeyInteger"));

      } else if (ET_COMPLEX_KEY.getName().equals(edmFQName.getName())) {
        final List<Property> properties = new ArrayList<Property>();
        properties.add(new SimpleProperty().setName("KeyString")
            .setType(EdmSimpleTypeKind.String)
            .setFacets(new Facets().setNullable(false)));
        properties.add(new SimpleProperty().setName("KeyInteger")
            .setType(EdmSimpleTypeKind.String)
            .setFacets(new Facets().setNullable(false)));

        return new EntityType().setName(ET_COMPLEX_KEY.getName()).setProperties(properties).setKey(
            createKey("KeyInteger", "KeyString"));
      } else if (ET_ALL_TYPES.getName().equals(edmFQName.getName())) {
        final List<Property> properties = new ArrayList<Property>();
        properties.add(new SimpleProperty().setName("Boolean").setType(EdmSimpleTypeKind.Boolean));
        properties.add(new SimpleProperty().setName("Binary").setType(EdmSimpleTypeKind.Binary));
        properties.add(new SimpleProperty().setName("Byte").setType(EdmSimpleTypeKind.Byte));
        properties.add(new SimpleProperty().setName("DateTime").setType(EdmSimpleTypeKind.DateTime));
        properties.add(new SimpleProperty().setName("DateTimeOffset").setType(EdmSimpleTypeKind.DateTimeOffset));
        properties.add(new SimpleProperty().setName("Decimal").setType(EdmSimpleTypeKind.Decimal));
        properties.add(new SimpleProperty().setName("Double").setType(EdmSimpleTypeKind.Double));
        properties.add(new SimpleProperty().setName("Guid").setType(EdmSimpleTypeKind.Guid));
        properties.add(new SimpleProperty().setName("Int16").setType(EdmSimpleTypeKind.Int16));
        properties.add(new SimpleProperty().setName("Int32").setType(EdmSimpleTypeKind.Int32));
        properties.add(new SimpleProperty().setName("Int64").setType(EdmSimpleTypeKind.Int64));
        properties.add(new SimpleProperty().setName("SByte").setType(EdmSimpleTypeKind.SByte));
        properties.add(new SimpleProperty().setName("Single").setType(EdmSimpleTypeKind.Single));
        properties.add(new SimpleProperty().setName("String").setType(EdmSimpleTypeKind.String));
        properties.add(new SimpleProperty().setName("Time").setType(EdmSimpleTypeKind.Time));
        properties.add(new ComplexProperty().setName("Complex").setType(CT_ALL_TYPES));
        return new EntityType().setName(ET_ALL_TYPES.getName()).setProperties(properties);
      } else if (ET_STRING_FACETS.getName().equals(edmFQName.getName())) {
        final List<Property> properties = new ArrayList<Property>();

        properties.add(new SimpleProperty().setName("StringDefaultValue").setType(EdmSimpleTypeKind.String)
            .setFacets(new Facets().setDefaultValue("defaultValue")));

        properties.add(new SimpleProperty().setName("StringFixedLength").setType(EdmSimpleTypeKind.String)
            .setFacets(new Facets().setFixedLength(true)));

        properties.add(new SimpleProperty().setName("StringMaxLength").setType(EdmSimpleTypeKind.String)
            .setFacets(new Facets().setMaxLength(15)));

        properties.add(new SimpleProperty().setName("StringLength").setType(EdmSimpleTypeKind.String)
            .setFacets(new Facets().setMaxLength(15).setFixedLength(true)));

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

        properties.add(new SimpleProperty().setName("StringUnicode").setType(EdmSimpleTypeKind.String)
            .setFacets(new Facets().setUnicode(false)));

        return new EntityType().setName(ET_STRING_FACETS.getName()).setProperties(properties);
      }
    }
View Full Code Here

        annoList.add(new AnnotationAttribute().setName("annoName").setNamespace("http://annoNamespace").setPrefix(
            "annoPrefix").setText("annoText"));
        annoList.add(new AnnotationAttribute().setName("annoName2").setNamespace("http://annoNamespace").setPrefix(
            "annoPrefix").setText("annoText2"));
        properties.add(new SimpleProperty().setName("EmployeeId").setType(EdmSimpleTypeKind.String)
            .setFacets(new Facets().setNullable(false))
            .setMapping(new Mapping().setInternalName("getId")).setAnnotationAttributes(annoList));
        final ArrayList<AnnotationAttribute> annoList2 = new ArrayList<AnnotationAttribute>();
        annoList2.add(new AnnotationAttribute().setName("annoName").setNamespace("http://annoNamespace").setPrefix(
            "annoPrefix").setText("annoText"));

        final List<AnnotationElement> annoElementsForSimpleProp = new ArrayList<AnnotationElement>();
        annoElementsForSimpleProp.add(new AnnotationElement().setName("propertyAnnoElement").setText("text"));
        annoElementsForSimpleProp.add(new AnnotationElement().setName("propertyAnnoElement2"));
        final SimpleProperty simpleProp =
            new SimpleProperty().setName("EmployeeName").setType(EdmSimpleTypeKind.String)
                .setCustomizableFeedMappings(new CustomizableFeedMappings()
                    .setFcTargetPath(EdmTargetPath.SYNDICATION_TITLE)).setAnnotationAttributes(annoList2)
                .setAnnotationElements(annoElementsForSimpleProp);

        properties.add(simpleProp);
        final ArrayList<AnnotationAttribute> annoList3 = new ArrayList<AnnotationAttribute>();
        annoList3.add(new AnnotationAttribute().setName("annoName").setNamespace("http://annoNamespaceNew").setPrefix(
            "annoPrefix").setText("annoTextNew"));
        properties.add(new SimpleProperty().setName("ManagerId").setType(EdmSimpleTypeKind.String)
            .setMapping(new Mapping().setInternalName("getManager.getId")).setAnnotationAttributes(annoList3));
        properties.add(new SimpleProperty().setName("RoomId").setType(EdmSimpleTypeKind.String)
            .setMapping(new Mapping().setInternalName("getRoom.getId")));
        properties.add(new SimpleProperty().setName("TeamId").setType(EdmSimpleTypeKind.String)
            .setFacets(new Facets().setMaxLength(2))
            .setMapping(new Mapping().setInternalName("getTeam.getId")));
        properties.add(new ComplexProperty().setName("Location").setType(COMPLEX_TYPE_1));
        properties.add(new SimpleProperty().setName("Age").setType(EdmSimpleTypeKind.Int16));
        properties.add(new SimpleProperty().setName("EntryDate").setType(EdmSimpleTypeKind.DateTime)
            .setFacets(new Facets().setNullable(true))
            .setCustomizableFeedMappings(
                new CustomizableFeedMappings().setFcTargetPath(EdmTargetPath.SYNDICATION_UPDATED)));
        properties.add(new SimpleProperty().setName("ImageUrl").setType(EdmSimpleTypeKind.String)
            .setMapping(new Mapping().setInternalName("getImageUri")));
        final List<NavigationProperty> navigationProperties = new ArrayList<NavigationProperty>();
        navigationProperties.add(new NavigationProperty().setName("ne_Manager")
            .setRelationship(ASSOCIATION_1_1).setFromRole(ROLE_1_1).setToRole(ROLE_1_4));
        navigationProperties.add(new NavigationProperty().setName("ne_Team")
            .setRelationship(ASSOCIATION_1_2).setFromRole(ROLE_1_1).setToRole(ROLE_1_2));
        navigationProperties.add(new NavigationProperty().setName("ne_Room")
            .setRelationship(ASSOCIATION_1_3).setFromRole(ROLE_1_1).setToRole(ROLE_1_3));
        return new EntityType().setName(ENTITY_TYPE_1_1.getName())
            .setProperties(properties)
            .setHasStream(true)
            .setKey(getKey("EmployeeId"))
            .setNavigationProperties(navigationProperties)
            .setMapping(new Mapping().setMimeType("getImageType"));

      } else if (ENTITY_TYPE_1_BASE.getName().equals(edmFQName.getName())) {
        final List<Property> properties = new ArrayList<Property>();
        properties.add(new SimpleProperty().setName("Id").setType(EdmSimpleTypeKind.String)
            .setFacets(new Facets().setNullable(false).setDefaultValue("1")));
        properties.add(new SimpleProperty().setName("Name").setType(EdmSimpleTypeKind.String)
            .setCustomizableFeedMappings(
                new CustomizableFeedMappings().setFcTargetPath(EdmTargetPath.SYNDICATION_TITLE)));
        return new EntityType().setName(ENTITY_TYPE_1_BASE.getName())
            .setAbstract(true)
            .setProperties(properties)
            .setKey(getKey("Id"));

      } else if (ENTITY_TYPE_1_2.getName().equals(edmFQName.getName())) {
        final List<Property> properties = new ArrayList<Property>();
        properties.add(new SimpleProperty().setName("isScrumTeam").setType(EdmSimpleTypeKind.Boolean)
            .setFacets(new Facets().setNullable(true))
            .setMapping(new Mapping().setInternalName("isScrumTeam")));
        final List<NavigationProperty> navigationProperties = new ArrayList<NavigationProperty>();
        navigationProperties.add(new NavigationProperty().setName("nt_Employees")
            .setRelationship(ASSOCIATION_1_2).setFromRole(ROLE_1_2).setToRole(ROLE_1_1));
        return new EntityType().setName(ENTITY_TYPE_1_2.getName())
            .setBaseType(ENTITY_TYPE_1_BASE)
            .setProperties(properties)
            .setNavigationProperties(navigationProperties);

      } else if (ENTITY_TYPE_1_3.getName().equals(edmFQName.getName())) {
        final List<Property> properties = new ArrayList<Property>();
        properties.add(new SimpleProperty().setName("Seats").setType(EdmSimpleTypeKind.Int16));
        properties.add(new SimpleProperty().setName("Version").setType(EdmSimpleTypeKind.Int16)
            .setFacets(new Facets().setConcurrencyMode(EdmConcurrencyMode.Fixed)));
        final List<NavigationProperty> navigationProperties = new ArrayList<NavigationProperty>();
        navigationProperties.add(new NavigationProperty().setName("nr_Employees")
            .setRelationship(ASSOCIATION_1_3).setFromRole(ROLE_1_3).setToRole(ROLE_1_1));
        navigationProperties.add(new NavigationProperty().setName("nr_Building")
            .setRelationship(ASSOCIATION_1_4).setFromRole(ROLE_1_3).setToRole(ROLE_1_5));
        return new EntityType().setName(ENTITY_TYPE_1_3.getName())
            .setBaseType(ENTITY_TYPE_1_BASE)
            .setProperties(properties)
            .setNavigationProperties(navigationProperties);

      } else if (ENTITY_TYPE_1_4.getName().equals(edmFQName.getName())) {
        final List<NavigationProperty> navigationProperties = new ArrayList<NavigationProperty>();
        navigationProperties.add(new NavigationProperty().setName("nm_Employees")
            .setRelationship(ASSOCIATION_1_1).setFromRole(ROLE_1_4).setToRole(ROLE_1_1));
        return new EntityType().setName(ENTITY_TYPE_1_4.getName())
            .setBaseType(ENTITY_TYPE_1_1)
            .setHasStream(true)
            .setNavigationProperties(navigationProperties)
            .setMapping(new Mapping().setMimeType("getImageType"));

      } else if (ENTITY_TYPE_1_5.getName().equals(edmFQName.getName())) {
        final 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_AUTHORNAME)));
        properties.add(new SimpleProperty().setName("Image").setType(EdmSimpleTypeKind.Binary));
        final List<NavigationProperty> navigationProperties = new ArrayList<NavigationProperty>();
        navigationProperties.add(new NavigationProperty().setName("nb_Rooms")
            .setRelationship(ASSOCIATION_1_4).setFromRole(ROLE_1_5).setToRole(ROLE_1_3));
        return new EntityType().setName(ENTITY_TYPE_1_5.getName())
            .setProperties(properties)
            .setKey(getKey("Id"))
            .setNavigationProperties(navigationProperties);
      }

    } else if (NAMESPACE_2.equals(edmFQName.getNamespace())) {
      if (ENTITY_TYPE_2_1.getName().equals(edmFQName.getName())) {
        final List<Property> properties = new ArrayList<Property>();
        properties.add(new SimpleProperty().setName("Id").setType(EdmSimpleTypeKind.Int32)
            .setFacets(new Facets().setNullable(false).setConcurrencyMode(EdmConcurrencyMode.Fixed)));
        properties.add(new SimpleProperty().setName("Name").setType(EdmSimpleTypeKind.String)
            .setCustomizableFeedMappings(
                new CustomizableFeedMappings().setFcTargetPath(EdmTargetPath.SYNDICATION_TITLE)));
        properties.add(new SimpleProperty().setName("Type").setType(EdmSimpleTypeKind.String)
            .setFacets(new Facets().setNullable(false)));
        properties.add(new SimpleProperty().setName("ImageUrl").setType(EdmSimpleTypeKind.String)
            .setCustomizableFeedMappings(
                new CustomizableFeedMappings().setFcTargetPath(EdmTargetPath.SYNDICATION_AUTHORURI))
            .setMapping(new Mapping().setInternalName("getImageUri")));
        properties.add(new SimpleProperty().setName("Image").setType(EdmSimpleTypeKind.Binary)
            .setMapping(new Mapping().setMimeType("getType")));
        properties.add(new SimpleProperty().setName("BinaryData").setType(EdmSimpleTypeKind.Binary)
            .setFacets(new Facets().setNullable(true))
            .setMimeType("image/jpeg"));
        properties.add(new SimpleProperty().setName("Содержание").setType(EdmSimpleTypeKind.String)
            .setFacets(new Facets().setNullable(true))
            .setCustomizableFeedMappings(new CustomizableFeedMappings()
                .setFcKeepInContent(false)
                .setFcNsPrefix("ру") // CYRILLIC SMALL LETTER ER + CYRILLIC SMALL LETTER U
                .setFcNsUri("http://localhost")
                .setFcTargetPath("Содержание"))
View Full Code Here

  public FunctionImport getFunctionImport(final String entityContainer, final String name) throws ODataException {
    if (ENTITY_CONTAINER_1.equals(entityContainer)) {
      if (FUNCTION_IMPORT_1.equals(name)) {
        final List<FunctionImportParameter> parameters = new ArrayList<FunctionImportParameter>();
        parameters.add(new FunctionImportParameter().setName("q").setType(EdmSimpleTypeKind.String)
            .setFacets(new Facets().setNullable(true)));
        return new FunctionImport().setName(name)
            .setReturnType(new ReturnType().setTypeName(ENTITY_TYPE_1_1).setMultiplicity(EdmMultiplicity.MANY))
            .setEntitySet(ENTITY_SET_1_1)
            .setHttpMethod("GET")
            .setParameters(parameters);

      } 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)) {
        final List<FunctionImportParameter> parameters = new ArrayList<FunctionImportParameter>();
        parameters.add(new FunctionImportParameter().setName("Id").setType(EdmSimpleTypeKind.String)
            .setFacets(new Facets().setNullable(false)));
        return new FunctionImport().setName(name)
            .setReturnType(
                new ReturnType().setTypeName(EdmSimpleTypeKind.Binary.getFullQualifiedName()).setMultiplicity(
                    EdmMultiplicity.ONE))
            .setHttpMethod("GET")
View Full Code Here

  public EntityType getEntityType(final FullQualifiedName edmFQName) throws ODataException {
    if (NAMESPACE_1.equals(edmFQName.getNamespace())) {
      if (ENTITY_TYPE_1_1.getName().equals(edmFQName.getName())) {
        List<Property> properties = new ArrayList<Property>();
        properties.add(new SimpleProperty().setName("EmployeeId").setType(EdmSimpleTypeKind.String)
            .setFacets(new Facets().setNullable(false))
            .setMapping(new Mapping().setInternalName("getId")));
        properties.add(new SimpleProperty().setName("EmployeeName").setType(EdmSimpleTypeKind.String)
            .setCustomizableFeedMappings(new CustomizableFeedMappings()
                .setFcTargetPath(EdmTargetPath.SYNDICATION_TITLE)));
        properties.add(new SimpleProperty().setName("ManagerId").setType(EdmSimpleTypeKind.String)
            .setMapping(new Mapping().setInternalName("getManager.getId")));
        properties.add(new SimpleProperty().setName("RoomId").setType(EdmSimpleTypeKind.String)
            .setMapping(new Mapping().setInternalName("getRoom.getId")));
        properties.add(new SimpleProperty().setName("TeamId").setType(EdmSimpleTypeKind.String)
            .setFacets(new Facets().setMaxLength(2))
            .setMapping(new Mapping().setInternalName("getTeam.getId")));
        properties.add(new ComplexProperty().setName("Location").setType(COMPLEX_TYPE_1)
            .setFacets(new Facets().setNullable(false)));
        properties.add(new SimpleProperty().setName("Age").setType(EdmSimpleTypeKind.Int16));
        properties.add(new SimpleProperty().setName("EntryDate").setType(EdmSimpleTypeKind.DateTime)
            .setFacets(new Facets().setNullable(true))
            .setCustomizableFeedMappings(new CustomizableFeedMappings()
                .setFcTargetPath(EdmTargetPath.SYNDICATION_UPDATED)));
        properties.add(new SimpleProperty().setName("ImageUrl").setType(EdmSimpleTypeKind.String)
            .setMapping(new Mapping().setInternalName("getImageUri")));
        List<NavigationProperty> navigationProperties = new ArrayList<NavigationProperty>();
        navigationProperties.add(new NavigationProperty().setName("ne_Manager")
            .setRelationship(ASSOCIATION_1_1).setFromRole(ROLE_1_1).setToRole(ROLE_1_4));
        navigationProperties.add(new NavigationProperty().setName("ne_Team")
            .setRelationship(ASSOCIATION_1_2).setFromRole(ROLE_1_1).setToRole(ROLE_1_2));
        navigationProperties.add(new NavigationProperty().setName("ne_Room")
            .setRelationship(ASSOCIATION_1_3).setFromRole(ROLE_1_1).setToRole(ROLE_1_3));
        return new EntityType().setName(ENTITY_TYPE_1_1.getName())
            .setProperties(properties)
            .setHasStream(true)
            .setKey(getKey("EmployeeId"))
            .setNavigationProperties(navigationProperties)
            .setMapping(new Mapping().setMimeType("getImageType"));

      } else if (ENTITY_TYPE_1_BASE.getName().equals(edmFQName.getName())) {
        List<Property> properties = new ArrayList<Property>();
        properties.add(new SimpleProperty().setName("Id").setType(EdmSimpleTypeKind.String)
            .setFacets(new Facets().setNullable(false).setDefaultValue("1")));
        properties.add(new SimpleProperty().setName("Name").setType(EdmSimpleTypeKind.String)
            .setCustomizableFeedMappings(new CustomizableFeedMappings()
                .setFcTargetPath(EdmTargetPath.SYNDICATION_TITLE)));
        return new EntityType().setName(ENTITY_TYPE_1_BASE.getName())
            .setAbstract(true)
            .setProperties(properties)
            .setKey(getKey("Id"));

      } else if (ENTITY_TYPE_1_2.getName().equals(edmFQName.getName())) {
        List<Property> properties = new ArrayList<Property>();
        properties.add(new SimpleProperty().setName("isScrumTeam").setType(EdmSimpleTypeKind.Boolean)
            .setFacets(new Facets().setNullable(true))
            .setMapping(new Mapping().setInternalName("isScrumTeam")));
        List<NavigationProperty> navigationProperties = new ArrayList<NavigationProperty>();
        navigationProperties.add(new NavigationProperty().setName("nt_Employees")
            .setRelationship(ASSOCIATION_1_2).setFromRole(ROLE_1_2).setToRole(ROLE_1_1));
        return new EntityType().setName(ENTITY_TYPE_1_2.getName())
            .setBaseType(ENTITY_TYPE_1_BASE)
            .setProperties(properties)
            .setNavigationProperties(navigationProperties);

      } else if (ENTITY_TYPE_1_3.getName().equals(edmFQName.getName())) {
        List<Property> properties = new ArrayList<Property>();
        properties.add(new SimpleProperty().setName("Seats").setType(EdmSimpleTypeKind.Int16));
        properties.add(new SimpleProperty().setName("Version").setType(EdmSimpleTypeKind.Int16)
            .setFacets(new Facets().setConcurrencyMode(EdmConcurrencyMode.Fixed)));
        List<NavigationProperty> navigationProperties = new ArrayList<NavigationProperty>();
        navigationProperties.add(new NavigationProperty().setName("nr_Employees")
            .setRelationship(ASSOCIATION_1_3).setFromRole(ROLE_1_3).setToRole(ROLE_1_1));
        navigationProperties.add(new NavigationProperty().setName("nr_Building")
            .setRelationship(ASSOCIATION_1_4).setFromRole(ROLE_1_3).setToRole(ROLE_1_5));
        return new EntityType().setName(ENTITY_TYPE_1_3.getName())
            .setBaseType(ENTITY_TYPE_1_BASE)
            .setProperties(properties)
            .setNavigationProperties(navigationProperties);

      } else if (ENTITY_TYPE_1_4.getName().equals(edmFQName.getName())) {
        List<NavigationProperty> navigationProperties = new ArrayList<NavigationProperty>();
        navigationProperties.add(new NavigationProperty().setName("nm_Employees")
            .setRelationship(ASSOCIATION_1_1).setFromRole(ROLE_1_4).setToRole(ROLE_1_1));
        return new EntityType().setName(ENTITY_TYPE_1_4.getName())
            .setBaseType(ENTITY_TYPE_1_1)
            .setHasStream(true)
            .setNavigationProperties(navigationProperties)
            .setMapping(new Mapping().setMimeType("getImageType"));

      } else if (ENTITY_TYPE_1_5.getName().equals(edmFQName.getName())) {
        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_AUTHORNAME)));
        properties.add(new SimpleProperty().setName("Image").setType(EdmSimpleTypeKind.Binary));
        List<NavigationProperty> navigationProperties = new ArrayList<NavigationProperty>();
        navigationProperties.add(new NavigationProperty().setName("nb_Rooms")
            .setRelationship(ASSOCIATION_1_4).setFromRole(ROLE_1_5).setToRole(ROLE_1_3));
        return new EntityType().setName(ENTITY_TYPE_1_5.getName())
            .setProperties(properties)
            .setKey(getKey("Id"))
            .setNavigationProperties(navigationProperties);
      }

    } else if (NAMESPACE_2.equals(edmFQName.getNamespace())) {
      if (ENTITY_TYPE_2_1.getName().equals(edmFQName.getName())) {
        List<Property> properties = new ArrayList<Property>();
        properties.add(new SimpleProperty().setName("Id").setType(EdmSimpleTypeKind.Int32)
            .setFacets(new Facets().setNullable(false).setConcurrencyMode(EdmConcurrencyMode.Fixed)));
        properties.add(new SimpleProperty().setName("Name").setType(EdmSimpleTypeKind.String)
            .setCustomizableFeedMappings(new CustomizableFeedMappings()
                .setFcTargetPath(EdmTargetPath.SYNDICATION_TITLE)));
        properties.add(new SimpleProperty().setName("Type").setType(EdmSimpleTypeKind.String)
            .setFacets(new Facets().setNullable(false)));
        properties.add(new SimpleProperty().setName("ImageUrl").setType(EdmSimpleTypeKind.String)
            .setCustomizableFeedMappings(new CustomizableFeedMappings()
                .setFcTargetPath(EdmTargetPath.SYNDICATION_AUTHORURI))
            .setMapping(new Mapping().setInternalName("getImageUri")));
        properties.add(new SimpleProperty().setName("Image").setType(EdmSimpleTypeKind.Binary)
            .setMapping(new Mapping().setMimeType("getImageType")));
        properties.add(new SimpleProperty().setName("BinaryData").setType(EdmSimpleTypeKind.Binary)
            .setFacets(new Facets().setNullable(true))
            .setMimeType("image/jpeg"));
        properties.add(new SimpleProperty().setName("Содержание").setType(EdmSimpleTypeKind.String)
            .setFacets(new Facets().setNullable(true))
            .setCustomizableFeedMappings(new CustomizableFeedMappings()
                .setFcKeepInContent(false)
                .setFcNsPrefix("ру") // CYRILLIC SMALL LETTER ER + CYRILLIC SMALL LETTER U
                .setFcNsUri("http://localhost")
                .setFcTargetPath("Содержание"))
View Full Code Here

  public ComplexType getComplexType(final FullQualifiedName edmFQName) throws ODataException {
    if (NAMESPACE_1.equals(edmFQName.getNamespace())) {
      if (COMPLEX_TYPE_1.getName().equals(edmFQName.getName())) {
        List<Property> properties = new ArrayList<Property>();
        properties.add(new ComplexProperty().setName("City").setType(COMPLEX_TYPE_2).setFacets(
            new Facets().setNullable(false)));
        properties.add(new SimpleProperty().setName("Country").setType(EdmSimpleTypeKind.String));
        return new ComplexType().setName(COMPLEX_TYPE_1.getName()).setProperties(properties);

      } else if (COMPLEX_TYPE_2.getName().equals(edmFQName.getName())) {
        List<Property> properties = new ArrayList<Property>();
View Full Code Here

TOP

Related Classes of org.apache.olingo.odata2.api.edm.provider.Facets

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.