org.apache.olingo.odata2.api.edm.provider.Key Java Examples
The following examples show how to use
org.apache.olingo.odata2.api.edm.provider.Key.
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 |
private Key readEntityTypeKey(final XMLStreamReader reader) throws XMLStreamException, EntityProviderException { reader.require(XMLStreamConstants.START_ELEMENT, edmNamespace, XmlMetadataConstants.EDM_ENTITY_TYPE_KEY); List<PropertyRef> keys = new ArrayList<PropertyRef>(); List<AnnotationElement> annotationElements = new ArrayList<AnnotationElement>(); List<AnnotationAttribute> annotationAttributes = readAnnotationAttribute(reader); while (reader.hasNext() && !(reader.isEndElement() && edmNamespace.equals(reader.getNamespaceURI()) && XmlMetadataConstants.EDM_ENTITY_TYPE_KEY.equals(reader.getLocalName()))) { reader.next(); if (reader.isStartElement()) { extractNamespaces(reader); currentHandledStartTagName = reader.getLocalName(); if (XmlMetadataConstants.EDM_PROPERTY_REF.equals(currentHandledStartTagName)) { reader.require(XMLStreamConstants.START_ELEMENT, edmNamespace, XmlMetadataConstants.EDM_PROPERTY_REF); keys.add(readPropertyRef(reader)); } else { annotationElements.add(readAnnotationElement(reader)); } } } Key key = new Key().setKeys(keys).setAnnotationAttributes(annotationAttributes); if (!annotationElements.isEmpty()) { key.setAnnotationElements(annotationElements); } return key; }
Example #2
Source File: AnnotationEdmProvider.java From olingo-odata2 with Apache License 2.0 | 6 votes |
public EntityType buildEntityType() { EntityType entityType = new EntityType(); if (baseEntityType != null) { entityType.setBaseType(baseEntityType); } if (!keyProperties.isEmpty()) { entityType.setKey(new Key().setKeys(keyProperties)); } if (!navProperties.isEmpty()) { entityType.setNavigationProperties(navProperties); } return entityType.setName(name) .setAbstract(isAbstract) .setHasStream(isMediaResource) .setProperties(properties) .setMapping(new Mapping().setMediaResourceMimeTypeKey(mediaResourceMimeTypeKey) .setMediaResourceSourceKey(mediaResourceSourceKey)); }
Example #3
Source File: NetworkEntitySet.java From DataHubSystem with GNU Affero General Public License v3.0 | 5 votes |
@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 #4
Source File: EdmTestProvider.java From olingo-odata2 with Apache License 2.0 | 5 votes |
private Key getKey(final String... keyNames) { final List<PropertyRef> keyProperties = new ArrayList<PropertyRef>(); for (final String keyName : keyNames) { keyProperties.add(new PropertyRef().setName(keyName)); } return new Key().setKeys(keyProperties); }
Example #5
Source File: TechnicalScenarioEdmProvider.java From olingo-odata2 with Apache License 2.0 | 5 votes |
private Key createKey(final String... keyNames) { final List<PropertyRef> keyProperties = new ArrayList<PropertyRef>(); for (final String keyName : keyNames) { keyProperties.add(new PropertyRef().setName(keyName)); } return new Key().setKeys(keyProperties); }
Example #6
Source File: ScenarioEdmProvider.java From olingo-odata2 with Apache License 2.0 | 5 votes |
private Key getKey(final String... keyNames) { List<PropertyRef> keyProperties = new ArrayList<PropertyRef>(); for (final String keyName : keyNames) { keyProperties.add(new PropertyRef().setName(keyName)); } return new Key().setKeys(keyProperties); }
Example #7
Source File: EdmSchemaMock.java From olingo-odata2 with Apache License 2.0 | 5 votes |
private static Key createKey(final String[] keyNames) { Key key = new Key(); List<PropertyRef> keys = new ArrayList<PropertyRef>(); for (String keyName : keyNames) { keys.add(new PropertyRef().setName(keyName)); } key.setKeys(keys); return null; }
Example #8
Source File: AnnotationEdmProviderTest.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@Test public void entityTypePhotoWithTwoKeyProperties() throws Exception { // validate team EntityType photo = aep.getEntityType(new FullQualifiedName(ModelSharedConstants.NAMESPACE_1, "Photo")); assertEquals("Photo", photo.getName()); final List<Property> properties = photo.getProperties(); assertEquals(5, properties.size()); assertTrue(containsProperty(properties, "Name")); assertTrue(containsProperty(properties, "ImageFormat")); assertTrue(containsProperty(properties, "MimeType")); assertTrue(containsProperty(properties, "ImageUrl")); assertTrue(containsProperty(properties, "Image")); assertFalse(photo.isAbstract()); assertTrue(photo.isHasStream()); assertEquals("MimeType",photo.getMapping().getMediaResourceMimeTypeKey()); assertEquals("ImageUrl",photo.getMapping().getMediaResourceSourceKey()); Key photoKey = photo.getKey(); List<PropertyRef> keyReferences = photoKey.getKeys(); assertEquals(2, keyReferences.size()); PropertyRef name = getPropertyRef(keyReferences, "Name"); assertEquals("Name", name.getName()); PropertyRef imageFormat = getPropertyRef(keyReferences, "ImageFormat"); assertEquals("ImageFormat", imageFormat.getName()); // assertEquals(0, photo.getNavigationProperties().size()); assertNull(photo.getNavigationProperties()); }
Example #9
Source File: SystemRoleEntitySet.java From DataHubSystem with GNU Affero General Public License v3.0 | 5 votes |
@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: ClassEntitySet.java From DataHubSystem with GNU Affero General Public License v3.0 | 5 votes |
@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 #11
Source File: CollectionEntitySet.java From DataHubSystem with GNU Affero General Public License v3.0 | 5 votes |
@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 #12
Source File: NetworkStatisticEntitySet.java From DataHubSystem with GNU Affero General Public License v3.0 | 5 votes |
@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: RestrictionEntitySet.java From DataHubSystem with GNU Affero General Public License v3.0 | 5 votes |
@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 #14
Source File: ItemEntitySet.java From DataHubSystem with GNU Affero General Public License v3.0 | 5 votes |
@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 #15
Source File: IngestEntitySet.java From DataHubSystem with GNU Affero General Public License v3.0 | 4 votes |
@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); }
Example #16
Source File: UserSynchronizerEntitySet.java From DataHubSystem with GNU Affero General Public License v3.0 | 4 votes |
@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: ConnectionEntitySet.java From DataHubSystem with GNU Affero General Public License v3.0 | 4 votes |
@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 #18
Source File: JPAEdmKey.java From olingo-odata2 with Apache License 2.0 | 4 votes |
@Override public Key getEdmKey() { return key; }
Example #19
Source File: JPAEdmTestModelView.java From olingo-odata2 with Apache License 2.0 | 4 votes |
@Override public Key getEdmKey() { return null; }
Example #20
Source File: XmlMetadataConsumer.java From olingo-odata2 with Apache License 2.0 | 4 votes |
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 #21
Source File: UserEntitySet.java From DataHubSystem with GNU Affero General Public License v3.0 | 4 votes |
@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 #22
Source File: XmlMetadataProducerTest.java From olingo-odata2 with Apache License 2.0 | 4 votes |
@Test public void writeValidMetadata3() throws Exception { List<Schema> schemas = new ArrayList<Schema>(); List<AnnotationElement> annotationElements = new ArrayList<AnnotationElement>(); annotationElements.add(new AnnotationElement().setName("test").setText("hallo)")); Schema schema = new Schema().setAnnotationElements(annotationElements); schema.setNamespace("http://namespace.com"); schemas.add(schema); List<PropertyRef> keys = new ArrayList<PropertyRef>(); keys.add(new PropertyRef().setName("Id")); Key key = new Key().setKeys(keys); List<Property> properties = new ArrayList<Property>(); properties.add(new SimpleProperty().setName("Id").setType(EdmSimpleTypeKind.String)); EntityType entityType = new EntityType().setName("testType").setKey(key).setProperties(properties); entityType.setDocumentation(new Documentation()); List<PropertyRef> keys2 = new ArrayList<PropertyRef>(); keys2.add(new PropertyRef().setName("SecondId")); Key key2 = new Key().setKeys(keys2); List<Property> properties2 = new ArrayList<Property>(); properties2.add(new SimpleProperty().setName("SecondId").setType(EdmSimpleTypeKind.String)); EntityType entityType2 = new EntityType().setName("SecondTestType").setKey(key2).setProperties(properties2); entityType2.setDocumentation(new Documentation().setSummary("Doc_TlDr").setLongDescription("Some long desc.")); List<EntityType> entityTypes = new ArrayList<EntityType>(); entityTypes.add(entityType); entityTypes.add(entityType2); schema.setEntityTypes(entityTypes); DataServices data = new DataServices().setSchemas(schemas).setDataServiceVersion(ODataServiceVersion.V20); CircleStreamBuffer csb = new CircleStreamBuffer(); OutputStreamWriter writer = new OutputStreamWriter(csb.getOutputStream(), "UTF-8"); XMLStreamWriter xmlStreamWriter = xmlStreamWriterFactory.createXMLStreamWriter(writer); XmlMetadataProducer.writeMetadata(data, xmlStreamWriter, null); Map<String, String> prefixMap = new HashMap<String, String>(); prefixMap.put("edmx", "http://schemas.microsoft.com/ado/2007/06/edmx"); prefixMap.put("a", "http://schemas.microsoft.com/ado/2008/09/edm"); NamespaceContext ctx = new SimpleNamespaceContext(prefixMap); XMLUnit.setXpathNamespaceContext(ctx); String metadata = StringHelper.inputStreamToString(csb.getInputStream()); assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:test", metadata); assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/a:EntityType[@Name=\"testType\"]", metadata); assertXpathExists("/edmx:Edmx/edmx:DataServices/a:Schema/" + "a:EntityType[@Name=\"SecondTestType\"]/a:Documentation/a:Summary", metadata); }
Example #23
Source File: EdmEntityTypeImplProvTest.java From olingo-odata2 with Apache License 2.0 | 4 votes |
@BeforeClass public static void getEdmEntityContainerImpl() throws Exception { edmProvider = mock(EdmProvider.class); EdmImplProv edmImplProv = new EdmImplProv(edmProvider); List<NavigationProperty> navigationProperties = new ArrayList<NavigationProperty>(); FullQualifiedName fooBarAssocName = new FullQualifiedName("namespace", "fooBarAssoc"); navigationProperties.add(new NavigationProperty().setName("fooBarNav").setFromRole("fromFoo").setRelationship( fooBarAssocName).setToRole("toBar")); EntityType fooEntityType = new EntityType().setName("fooEntityType").setNavigationProperties(navigationProperties); FullQualifiedName fooEntityTypeFullName = new FullQualifiedName("namespace", "fooEntityType"); when(edmProvider.getEntityType(fooEntityTypeFullName)).thenReturn(fooEntityType); List<Property> keyPropertysFoo = new ArrayList<Property>(); Property keyPropFoo = new SimpleProperty().setName("Id").setType(EdmSimpleTypeKind.String); keyPropertysFoo.add(keyPropFoo); fooEntityType.setProperties(keyPropertysFoo); PropertyRef refToKeyFoo = new PropertyRef().setName("Id"); List<PropertyRef> propRefKeysFoo = new ArrayList<PropertyRef>(); propRefKeysFoo.add(refToKeyFoo); Key fooTypeKey = new Key().setKeys(propRefKeysFoo); fooEntityType.setKey(fooTypeKey); edmEntityType = new EdmEntityTypeImplProv(edmImplProv, fooEntityType, "namespace"); FullQualifiedName barBaseTypeName = new FullQualifiedName("namespace", "barBase"); EntityType barBase = new EntityType().setName("barBase"); when(edmProvider.getEntityType(barBaseTypeName)).thenReturn(barBase); List<NavigationProperty> navigationPropertiesBarBase = new ArrayList<NavigationProperty>(); navigationPropertiesBarBase.add(new NavigationProperty().setName("barBaseNav")); barBase.setNavigationProperties(navigationPropertiesBarBase); List<Property> keyPropertysBarBase = new ArrayList<Property>(); Property keyPropBarBase = new SimpleProperty().setName("Id").setType(EdmSimpleTypeKind.String); keyPropertysBarBase.add(keyPropBarBase); keyPropBarBase = new SimpleProperty().setName("NotrmalProp").setType(EdmSimpleTypeKind.String); keyPropertysBarBase.add(keyPropBarBase); barBase.setProperties(keyPropertysBarBase); PropertyRef refToKeyBarBase = new PropertyRef().setName("Id"); List<PropertyRef> propRefKeysBarBase = new ArrayList<PropertyRef>(); propRefKeysBarBase.add(refToKeyBarBase); Key barBaseTypeKey = new Key().setKeys(propRefKeysBarBase); barBase.setKey(barBaseTypeKey); EntityType barEntityType = new EntityType().setName("barEntityType").setBaseType(barBaseTypeName); FullQualifiedName barEntityTypeFullName = new FullQualifiedName("namespace", "barEntityType"); when(edmProvider.getEntityType(barEntityTypeFullName)).thenReturn(barEntityType); edmEntityTypeWithBaseType = new EdmEntityTypeImplProv(edmImplProv, barEntityType, "namespace"); }
Example #24
Source File: SynchronizerEntitySet.java From DataHubSystem with GNU Affero General Public License v3.0 | 4 votes |
@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 #25
Source File: MapProvider.java From olingo-odata2 with Apache License 2.0 | 4 votes |
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); }
Example #26
Source File: JPAEdmKeyView.java From olingo-odata2 with Apache License 2.0 | 2 votes |
/** * The method returns an instance of EDM key for the given JPA EDM Entity * type. * * @return an instance of type {@link org.apache.olingo.odata2.api.edm.provider.Key} */ public Key getEdmKey();