private OEntity createEmployeeEntity() {
   EdmEntitySet entitySet = this.getMetadata().findEdmEntitySet("Employees");
   OEntityKey entityKey =
       OEntityKey.parse("EmployeeId='" + ServiceOperationsProducerMock.EMPLOYEE_ID + "'");
   ArrayList<OProperty<?>> properties = new ArrayList<OProperty<?>>();
   properties.add(OProperties.string("EmployeeName", ServiceOperationsProducerMock.EMPLOYEE_NAME));
   properties.add(OProperties.string("EmployeeId", ServiceOperationsProducerMock.EMPLOYEE_ID));
   OEntity entity = OEntities.create(entitySet, entityKey, properties, null);
   return entity;
 }
 /**
  * Transforms each object's field into OProperty and object into OEntity. Used by OData4J
  * framework to serialize output.
  *
  * @param namespace Namespace where this entity will be placed
  * @return This object encoded as OEntity
  */
 public OEntity asEntity(String namespace) {
   final List<OProperty<?>> properties = new ArrayList<OProperty<?>>();
   properties.add(OProperties.string("language", getLanguage()));
   properties.add(OProperties.string("value", getValue()));
   return OEntities.create(
       getEntitySet(namespace),
       OEntityKey.create(getLanguage()),
       properties,
       new ArrayList<OLink>(),
       getValue(),
       null);
 }
Пример #3
0
 private OEntity createCustomersEntity(EdmDataServices metadata) {
   EdmEntitySet entitySet = metadata.findEdmEntitySet("Customers");
   OEntityKey entityKey = OEntityKey.parse("CustomerID='12'");
   ArrayList<OProperty<?>> properties = new ArrayList<OProperty<?>>();
   properties.add(OProperties.string("CompanyName", "teiid"));
   properties.add(OProperties.string("ContactName", "contact-name"));
   properties.add(OProperties.string("ContactTitle", "contact-title"));
   properties.add(OProperties.string("Address", "address"));
   properties.add(OProperties.string("City", "city"));
   properties.add(OProperties.string("Region", "region"));
   properties.add(OProperties.string("PostalCode", "postal-code"));
   properties.add(OProperties.string("Country", "country"));
   properties.add(OProperties.string("Phone", "555-1212"));
   properties.add(OProperties.string("Fax", "555-1212"));
   OEntity entity = OEntities.create(entitySet, entityKey, properties, null);
   return entity;
 }
  private OEntity entityFromAtomEntry(
      EdmDataServices metadata,
      EdmEntitySet entitySet,
      DataServicesAtomEntry dsae,
      FeedCustomizationMapping mapping) {

    List<OProperty<?>> props = dsae.properties;
    if (mapping != null) {
      Enumerable<OProperty<?>> properties = Enumerable.create(dsae.properties);
      if (mapping.titlePropName != null)
        properties = properties.concat(OProperties.string(mapping.titlePropName, dsae.title));
      if (mapping.summaryPropName != null)
        properties = properties.concat(OProperties.string(mapping.summaryPropName, dsae.summary));

      props = properties.toList();
    }

    OEntityKey key =
        entityKey != null
            ? entityKey
            : dsae.id != null
                ? dsae.id.endsWith(")")
                    ? parseEntityKey(dsae.id)
                    : OEntityKey.infer(entitySet, props)
                : null;

    if (key == null)
      return OEntities.createRequest(
          entitySet,
          props,
          toOLinks(metadata, entitySet, dsae.atomLinks, mapping),
          dsae.title,
          dsae.categoryTerm);

    return OEntities.create(
        entitySet,
        key,
        props,
        toOLinks(metadata, entitySet, dsae.atomLinks, mapping),
        dsae.title,
        dsae.categoryTerm);
  }
  private OComplexObject createComplexTypeLocation() {
    ArrayList<OProperty<?>> propertiesCity = new ArrayList<OProperty<?>>();
    propertiesCity.add(OProperties.string("PostalCode", ServiceOperationsProducerMock.POSTAL_CODE));
    propertiesCity.add(OProperties.string("CityName", ServiceOperationsProducerMock.CITY));

    ArrayList<OProperty<?>> propertiesLocation = new ArrayList<OProperty<?>>();
    propertiesLocation.add(
        OProperties.complex(
            "City",
            this.getMetadata()
                .findEdmComplexType(ServiceOperationsProducerMock.COMPLEY_TYPE_NAME_CITY),
            propertiesCity));
    propertiesLocation.add(OProperties.string("Country", ServiceOperationsProducerMock.COUNTRY));

    OComplexObject locationType =
        OComplexObjects.create(
            this.getMetadata()
                .findEdmComplexType(ServiceOperationsProducerMock.COMPLEY_TYPE_NAME_LOCATION),
            propertiesLocation);

    return locationType;
  }
 /**
  * Transforms each object's field into OProperty and object into OEntity. Used by OData4J
  * framework to serialize output.
  *
  * @param ees Entity set that describes this object. This was defined in metadata for this object,
  *     see {@link org.informea.odata.pojo.AbstractContact#getSchema(String)}.
  * @return This object encoded as OEntity
  */
 @Override
 public OEntity asEntity(EdmEntitySet ees) {
   final List<OProperty<?>> properties = new ArrayList<OProperty<?>>();
   properties.add(OProperties.int16("protocolVersion", getProtocolVersion()));
   properties.add(OProperties.string("id", getId()));
   properties.add(OProperties.string("country", getCountry()));
   properties.add(OProperties.string("prefix", getPrefix()));
   properties.add(OProperties.string("firstName", getFirstName()));
   properties.add(OProperties.string("lastName", getLastName()));
   properties.add(OProperties.string("position", getPosition()));
   properties.add(OProperties.string("institution", getInstitution()));
   properties.add(OProperties.string("department", getDepartment()));
   properties.add(OProperties.string("address", getAddress()));
   properties.add(OProperties.string("email", getEmail()));
   properties.add(OProperties.string("phone", getPhoneNumber()));
   properties.add(OProperties.string("fax", getFax()));
   properties.add(OProperties.datetime("updated", getUpdated()));
   return OEntities.create(
       ees, OEntityKey.create(getId()), properties, new ArrayList<OLink>(), null, null);
 }