getFilterExtension(final CriteriaBuilder cb, final From, ?> from) {
13 |
14 | return cb.and(
15 | cb.equal(from.get(AnnotationsParent.CODE_PUBLISHER), "Eurostat"),
16 | cb.like(from.get(AnnotationsParent.CODE_ID), "LAU%"));
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/Membership.java:
--------------------------------------------------------------------------------
1 | package com.sap.olingo.jpa.processor.core.testmodel;
2 |
3 | import jakarta.persistence.Column;
4 | import jakarta.persistence.Entity;
5 | import jakarta.persistence.Id;
6 | import jakarta.persistence.IdClass;
7 | import jakarta.persistence.Table;
8 |
9 | import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmIgnore;
10 |
11 | @EdmIgnore
12 | @Entity
13 | @Table(schema = "\"OLINGO\"", name = "\"Membership\"")
14 | @IdClass(MembershipKey.class)
15 | public class Membership {
16 | @Id
17 | @Column(name = "\"PersonID\"", length = 32)
18 | private String personID;
19 | @Id
20 | @Column(name = "\"TeamID\"", length = 32)
21 | private String teamID;
22 | }
23 |
--------------------------------------------------------------------------------
/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/uri/JPASkipTokenOptionImpl.java:
--------------------------------------------------------------------------------
1 | package com.sap.olingo.jpa.processor.core.uri;
2 |
3 | import org.apache.olingo.server.api.uri.queryoption.SkipTokenOption;
4 | import org.apache.olingo.server.api.uri.queryoption.SystemQueryOptionKind;
5 |
6 | record JPASkipTokenOptionImpl(String skipToken) implements SkipTokenOption {
7 |
8 | @Override
9 | public SystemQueryOptionKind getKind() {
10 | return SystemQueryOptionKind.SKIPTOKEN;
11 | }
12 |
13 | @Override
14 | public String getName() {
15 | return null;
16 | }
17 |
18 | @Override
19 | public String getText() {
20 | return skipToken;
21 | }
22 |
23 | @Override
24 | public String getValue() {
25 | return skipToken;
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/jpa/odata-jpa-spring-support/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 |
5 |
6 | com.sap.olingo
7 | odata-jpa
8 | 2.4.1-SNAPSHOT
9 |
10 |
11 | odata-jpa-spring-support
12 |
13 |
14 | com.sap.hcp.cf.logging
15 | cf-java-logging-support-log4j2
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/.github/workflows/build-wo-cb.yml:
--------------------------------------------------------------------------------
1 | name: Build OData JPA Processor
2 | on:
3 | push:
4 | branches:
5 | - main
6 | pull_request:
7 | types: [opened, synchronize, reopened]
8 | jobs:
9 | build:
10 | runs-on: ubuntu-latest
11 | name: Build without criteria builder
12 | steps:
13 | - uses: actions/checkout@v6
14 | - name: Set up JDK to 17
15 | uses: actions/setup-java@v5
16 | with:
17 | java-version: 17
18 | distribution: 'temurin'
19 | cache: maven
20 | - name: 1. Build JPA
21 | run: cd ./jpa && mvn clean install -Dmaven.test.skip
22 | - name: 2. Build processor without criteria builder
23 | run: cd ./jpa && mvn --projects odata-jpa-processor -Pwo-extension clean install
24 |
--------------------------------------------------------------------------------
/jpa/odata-jpa-odata-vocabularies/src/main/java/com/sap/olingo/jpa/metadata/odata/v4/capabilities/terms/CountRestrictionsProperties.java:
--------------------------------------------------------------------------------
1 | package com.sap.olingo.jpa.metadata.odata.v4.capabilities.terms;
2 |
3 | import com.sap.olingo.jpa.metadata.core.edm.extension.vocabularies.PropertyAccess;
4 |
5 | public enum CountRestrictionsProperties implements PropertyAccess {
6 |
7 | COUNTABLE("Countable"),
8 | NON_COUNTABLE_PROPERTIES("NonCountableProperties"),
9 | NON_COUNTABLE_NAVIGATION_PROPERTIES("NonCountableNavigationProperties");
10 |
11 | private final String property;
12 |
13 | private CountRestrictionsProperties(final String property) {
14 | this.property = property;
15 | }
16 |
17 | @Override
18 | public String property() {
19 | return property;
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/ChangeInformation.java:
--------------------------------------------------------------------------------
1 | package com.sap.olingo.jpa.processor.core.errormodel;
2 |
3 | import java.util.Date;
4 |
5 | import jakarta.persistence.Column;
6 | import jakarta.persistence.Embeddable;
7 | import jakarta.persistence.Temporal;
8 | import jakarta.persistence.TemporalType;
9 |
10 | @Embeddable
11 | public class ChangeInformation {
12 |
13 | @Column
14 | private String by;
15 | @Column(precision = 9)
16 | @Temporal(TemporalType.TIMESTAMP)
17 | private Date at;
18 |
19 | String user;
20 |
21 | public ChangeInformation() {}
22 |
23 | public ChangeInformation(final String by, final Date at) {
24 | super();
25 | this.by = by;
26 | this.at = at;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/CurrentUser.java:
--------------------------------------------------------------------------------
1 | package com.sap.olingo.jpa.processor.core.testmodel;
2 |
3 | import jakarta.persistence.DiscriminatorValue;
4 | import jakarta.persistence.Entity;
5 |
6 | import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmEntityType;
7 | import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmTopLevelElementRepresentation;
8 |
9 | //Problem with multi-level inheritance hierarchy Inheritance Type SINGLE_TABLE. Therefore inherit also from
10 | //Business Partner
11 | @Entity(name = "CurrentUser")
12 | @DiscriminatorValue(value = "1")
13 | @EdmEntityType(as = EdmTopLevelElementRepresentation.AS_SINGLETON_ONLY,
14 | extensionProvider = CurrentUserQueryExtension.class)
15 | public class CurrentUser extends Person {}
16 |
--------------------------------------------------------------------------------
/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAExtension.java:
--------------------------------------------------------------------------------
1 | package com.sap.olingo.jpa.processor.core.query;
2 |
3 | import com.sap.olingo.jpa.processor.core.converter.JPAExpandResult;
4 |
5 | public interface JPAExtension {
6 | /**
7 | * Process a expand query, which contains a $skip and/or a $top option.
8 | * This a tricky problem, as it can not be done easily with SQL. It could be that a database offers special solutions.
9 | * There is an worth reading blog regards this topic:
10 | * How to select
11 | * the first/least/max row per group in SQL
12 | * @return query result
13 | */
14 | JPAExpandResult executeExpandTopSkipQuery();
15 | }
16 |
--------------------------------------------------------------------------------
/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/EmptyQueryExtensionProvider.java:
--------------------------------------------------------------------------------
1 | package com.sap.olingo.jpa.processor.core.testmodel;
2 |
3 | import jakarta.persistence.criteria.CriteriaBuilder;
4 | import jakarta.persistence.criteria.Expression;
5 | import jakarta.persistence.criteria.From;
6 |
7 | import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmQueryExtensionProvider;
8 |
9 | /**
10 | * Empty implementation to check inheritance of query provider.
11 | * @author Oliver Grande
12 | *
13 | */
14 | public class EmptyQueryExtensionProvider implements EdmQueryExtensionProvider {
15 |
16 | @Override
17 | public Expression getFilterExtension(final CriteriaBuilder cb, final From, ?> from) {
18 | return null;
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/SupportRelationship.java:
--------------------------------------------------------------------------------
1 | package com.sap.olingo.jpa.processor.core.testmodel;
2 |
3 | import jakarta.persistence.Column;
4 | import jakarta.persistence.Entity;
5 | import jakarta.persistence.Id;
6 | import jakarta.persistence.Table;
7 |
8 | import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmIgnore;
9 |
10 | @EdmIgnore
11 | @Entity
12 | @Table(schema = "\"OLINGO\"", name = "\"SupportRelationship\"")
13 | public class SupportRelationship {
14 | @Id
15 | @Column(name = "\"ID\"")
16 | private Integer iD;
17 |
18 | @Column(name = "\"OrganizationID\"", length = 32)
19 | private String organizationID;
20 |
21 | @Column(name = "\"PersonID\"", length = 32)
22 | private String personID;
23 | }
24 |
--------------------------------------------------------------------------------
/jpa-archetype/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | jpa-archetype
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.m2e.core.maven2Builder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.m2e.core.maven2Nature
16 |
17 |
18 |
19 | 1634102235489
20 |
21 | 30
22 |
23 | org.eclipse.core.resources.regexFilterMatcher
24 | node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/JPAExpandItemWrapperTest.java:
--------------------------------------------------------------------------------
1 | package com.sap.olingo.jpa.processor.core.query;
2 |
3 | import static org.mockito.Mockito.mock;
4 |
5 | import org.apache.olingo.server.api.uri.queryoption.ExpandItem;
6 | import org.junit.jupiter.api.BeforeEach;
7 |
8 | import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAEntityType;
9 |
10 | class JPAExpandItemWrapperTest extends JPAExpandItemPageableTest {
11 | private JPAExpandItemWrapper cut;
12 |
13 | @BeforeEach
14 | void setup() {
15 | et = mock(JPAEntityType.class);
16 | expandItem = mock(ExpandItem.class);
17 | cut = new JPAExpandItemWrapper(expandItem, et);
18 | }
19 |
20 | @Override
21 | JPAExpandItemPageable getCut() {
22 | return cut;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/NestedComplexKey.java:
--------------------------------------------------------------------------------
1 | package com.sap.olingo.jpa.processor.core.testmodel;
2 |
3 | import java.util.Objects;
4 |
5 | import jakarta.persistence.Column;
6 | import jakarta.persistence.Id;
7 |
8 | public class NestedComplexKey {
9 |
10 | @Id
11 | @Column(name = "\"ID\"")
12 | private String iD;
13 |
14 | @Id
15 | @Column(name = "\"Number\"")
16 | private Long number;
17 |
18 | @Override
19 | public int hashCode() {
20 | return Objects.hash(iD, number);
21 | }
22 |
23 | @Override
24 | public boolean equals(final Object obj) {
25 | if (obj instanceof final NestedComplexKey other)
26 | return Objects.equals(iD, other.iD) && Objects.equals(number, other.number);
27 | return false;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/jpa-tutorial/.asciidoctorconfig.adoc:
--------------------------------------------------------------------------------
1 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 | // + Initial AsciiDoc editor configuration file - V1.0 +
3 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 | //
5 | // Did not find any configuration files, so creating this at project root level.
6 | // If you do not like those files to be generated - you can turn it off inside Asciidoctor Editor preferences.
7 | //
8 | // You can define editor specific parts here.
9 | // For example: with next line you could set imagesdir attribute to subfolder "images" relative to the folder where this config file is located.
10 | // :imagesdir: {asciidoctorconfigdir}/images
11 | //
12 | // For more information please take a look at https://github.com/de-jcup/eclipse-asciidoctor-editor/wiki/Asciidoctor-configfiles
13 |
--------------------------------------------------------------------------------
/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestNotImplemented.java:
--------------------------------------------------------------------------------
1 | package com.sap.olingo.jpa.processor.core.query;
2 |
3 | import java.io.IOException;
4 |
5 | import org.apache.olingo.commons.api.ex.ODataException;
6 | import org.junit.jupiter.api.Test;
7 |
8 | import com.sap.olingo.jpa.processor.core.util.IntegrationTestHelper;
9 | import com.sap.olingo.jpa.processor.core.util.TestBase;
10 |
11 | class TestNotImplemented extends TestBase {
12 |
13 | @Test
14 | void testApplyThrowsException() throws IOException, ODataException {
15 |
16 | final IntegrationTestHelper helper = new IntegrationTestHelper(emf,
17 | "AdministrativeDivisions?$apply=aggregate(Area with sum as TotalArea)");
18 | helper.assertStatus(501);
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/InheritanceByJoinLockedSavingAccount.java:
--------------------------------------------------------------------------------
1 | package com.sap.olingo.jpa.processor.core.testmodel;
2 |
3 | import jakarta.persistence.Column;
4 | import jakarta.persistence.DiscriminatorValue;
5 | import jakarta.persistence.Entity;
6 | import jakarta.persistence.PrimaryKeyJoinColumn;
7 | import jakarta.persistence.Table;
8 |
9 | @DiscriminatorValue("LockedSavingAccount")
10 | @Entity(name = "InheritanceLockedSavingAccount")
11 | @Table(schema = "\"OLINGO\"", name = "\"InheritanceByJoinLockedSavingAccount\"")
12 | @PrimaryKeyJoinColumn(name = "\"AccountId\"")
13 | public class InheritanceByJoinLockedSavingAccount extends InheritanceByJoinSavingAccount {
14 |
15 | @Column(name = "\"LockingPeriod\"")
16 | private int lockingPeriod;
17 | }
18 |
--------------------------------------------------------------------------------
/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/RootImpl.java:
--------------------------------------------------------------------------------
1 | package com.sap.olingo.jpa.processor.cb.impl;
2 |
3 | import jakarta.persistence.criteria.CriteriaBuilder;
4 | import jakarta.persistence.criteria.Root;
5 | import jakarta.persistence.metamodel.EntityType;
6 |
7 | import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAEntityType;
8 | import com.sap.olingo.jpa.processor.cb.exceptions.NotImplementedException;
9 |
10 | class RootImpl extends FromImpl implements Root {
11 |
12 | RootImpl(final JPAEntityType type, final AliasBuilder aliasBuilder, final CriteriaBuilder cb) {
13 | super(type, aliasBuilder, cb);
14 | }
15 |
16 | @Override
17 | public EntityType getModel() {
18 | throw new NotImplementedException();
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/api/JPAODataClaimProviderTest.java:
--------------------------------------------------------------------------------
1 | package com.sap.olingo.jpa.processor.core.api;
2 |
3 | import static org.junit.jupiter.api.Assertions.assertFalse;
4 |
5 | import java.util.List;
6 | import java.util.Optional;
7 |
8 | import org.junit.jupiter.api.Test;
9 |
10 | class JPAODataClaimProviderTest {
11 |
12 | @Test
13 | void testDefaultImplementationsReturnsEmpty() {
14 | final JPAODataClaimProvider cut = new DummyImpl();
15 | final Optional act = cut.user();
16 | assertFalse(act.isPresent());
17 | }
18 |
19 | private static class DummyImpl implements JPAODataClaimProvider {
20 |
21 | @Override
22 | public List> get(final String attributeName) {
23 | return null;
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/StreetPropertyCalculator.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package com.sap.olingo.jpa.processor.core.testmodel;
5 |
6 | import jakarta.persistence.Tuple;
7 |
8 | import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmTransientPropertyCalculator;
9 |
10 | /**
11 | * @author Oliver Grande
12 | * Created: 17.03.2020
13 | *
14 | */
15 | public class StreetPropertyCalculator implements EdmTransientPropertyCalculator {
16 |
17 | @Override
18 | public String calculateProperty(final Tuple row) {
19 |
20 | return new StringBuffer()
21 | .append(row.get("Address/StreetName"))
22 | .append(" ")
23 | .append(row.get("Address/HouseNumber"))
24 | .toString();
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/jpa/odata-jpa-vocabularies/src/main/java/com/sap/olingo/jpa/metadata/core/edm/extension/vocabularies/ReferenceList.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package com.sap.olingo.jpa.metadata.core.edm.extension.vocabularies;
5 |
6 | import java.net.URI;
7 |
8 | import javax.annotation.Nonnull;
9 |
10 | /**
11 | * @author Oliver Grande
12 | * @since 1.1.1
13 | * 13.02.2023
14 | */
15 | public interface ReferenceList {
16 |
17 | /**
18 | * @param uri URI of the vocabulary e.g.
19 | * "http://docs.oasisopen.org/odata/odata/v4.0/os/vocabularies/Org.OData.Capabilities.V1.xml"
20 | * @param sub-path the vocabulary is stored within a resource folder
21 | * @return
22 | */
23 | ReferenceAccess addReference(@Nonnull final URI uri, @Nonnull final String path)
24 | throws ODataVocabularyReadException;
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/jpa/odata-jpa-vocabularies/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/vocabularies/EdmxDataServices.java:
--------------------------------------------------------------------------------
1 | package com.sap.olingo.jpa.metadata.core.edm.mapper.vocabularies;
2 |
3 | import java.util.Arrays;
4 | import java.util.List;
5 |
6 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
7 | import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
8 | import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
9 |
10 | @JsonIgnoreProperties(ignoreUnknown = true)
11 | @JacksonXmlRootElement(localName = "DataServices", namespace = "edmx")
12 | public class EdmxDataServices {
13 |
14 | @JacksonXmlProperty(localName = "Schema")
15 | private Schema[] schemas;
16 |
17 | List getSchemas() {
18 | return Arrays.asList(schemas);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/jpa-archetype/pom.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 | 4.0.0
5 | com.sap.olingo
6 | odata-jpa-archetype
7 | 2.4.1-SNAPSHOT
8 | pom
9 | https://github.com/SAP/olingo-jpa-processor-v4
10 |
11 |
12 | UTF-8
13 | 17
14 |
15 |
16 |
17 | odata-jpa-archetype-spring
18 |
19 |
--------------------------------------------------------------------------------
/jpa/odata-jpa-processor-parallel/README.md:
--------------------------------------------------------------------------------
1 | # Parallel Processing
2 |
3 | __This project is under construction! Feel free to try it.__
4 |
5 | This project contains JPA Processor enhancements to process OData requests in parallel. As a first step GET requests that a combined in a $batch request are executed in parallel. The parallel processing is used if the corresponding factory is provided via the service context:
6 |
7 | ```java
8 | .setBatchProcessorFactory(new JPAODataParallelBatchProcessorFactory())
9 | ```
10 |
11 | It shall be mentioned that the OData specification would allow a parallel processing only if the clients sends a `continue-on-error` header, see: [Preference continue-on-error (odata.continue-on-error)](https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#_Toc31358874)
12 |
--------------------------------------------------------------------------------
/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/ODATARequestContext.java:
--------------------------------------------------------------------------------
1 | package com.sap.olingo.jpa.processor.core.processor;
2 |
3 | import javax.annotation.Nonnull;
4 |
5 | import org.apache.olingo.server.api.uri.UriInfo;
6 |
7 | import com.sap.olingo.jpa.processor.core.exception.ODataJPAIllegalAccessException;
8 | import com.sap.olingo.jpa.processor.core.serializer.JPASerializer;
9 |
10 | interface ODATARequestContext {
11 |
12 | /**
13 | *
14 | * @param uriInfo
15 | * @throws ODataJPAIllegalAccessException In case UriInfo already exists e.g. because a page was provided
16 | */
17 | void setUriInfo(@Nonnull final UriInfo uriInfo) throws ODataJPAIllegalAccessException;
18 |
19 | void setJPASerializer(@Nonnull final JPASerializer serializer);
20 | }
21 |
--------------------------------------------------------------------------------
/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/FullNameCalculator.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package com.sap.olingo.jpa.processor.core.testmodel;
5 |
6 | import jakarta.persistence.Tuple;
7 |
8 | import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmTransientPropertyCalculator;
9 |
10 | /**
11 | * @author Oliver Grande
12 | * Created: 17.03.2020
13 | *
14 | */
15 | public class FullNameCalculator implements EdmTransientPropertyCalculator {
16 |
17 | @Override
18 | public String calculateProperty(final Tuple row) {
19 | final Person dummyPerson = new Person();
20 | dummyPerson.setFirstName((String) row.get("FirstName"));
21 | dummyPerson.setLastName((String) row.get("LastName"));
22 | return dummyPerson.getFullName();
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/jpa/odata-jpa-odata-vocabularies/src/main/java/com/sap/olingo/jpa/metadata/odata/v4/capabilities/terms/SortRestrictionsProperties.java:
--------------------------------------------------------------------------------
1 | package com.sap.olingo.jpa.metadata.odata.v4.capabilities.terms;
2 |
3 | import com.sap.olingo.jpa.metadata.core.edm.extension.vocabularies.PropertyAccess;
4 |
5 | public enum SortRestrictionsProperties implements PropertyAccess {
6 |
7 | SORTABLE("Sortable"),
8 | ASCENDING_ONLY_PROPERTIES("AscendingOnlyProperties"),
9 | DESCENDING_ONLE_PROPERTIES("DescendingOnlyProperties"),
10 | NON_SORTABLE_PROPERTIES("NonSortableProperties");
11 |
12 | private final String property;
13 |
14 | private SortRestrictionsProperties(final String property) {
15 | this.property = property;
16 | }
17 |
18 | @Override
19 | public String property() {
20 | return property;
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAComparisonOperator.java:
--------------------------------------------------------------------------------
1 | package com.sap.olingo.jpa.processor.core.filter;
2 |
3 | import jakarta.persistence.criteria.Expression;
4 |
5 | import org.apache.olingo.server.api.ODataApplicationException;
6 | import org.apache.olingo.server.api.uri.queryoption.expression.BinaryOperatorKind;
7 |
8 | public interface JPAComparisonOperator> extends JPAExpressionOperator {
9 |
10 | Expression getLeft() throws ODataApplicationException;
11 |
12 | Object getRight();
13 |
14 | Comparable getRightAsComparable() throws ODataApplicationException;
15 |
16 | Expression getRightAsExpression() throws ODataApplicationException;
17 |
18 | @SuppressWarnings("unchecked")
19 | @Override
20 | BinaryOperatorKind getOperator();
21 | }
--------------------------------------------------------------------------------
/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/testobjects/ExampleJavaOneAction.java:
--------------------------------------------------------------------------------
1 | package com.sap.olingo.jpa.metadata.core.edm.mapper.testobjects;
2 |
3 | import java.math.BigDecimal;
4 |
5 | import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmAction;
6 | import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmParameter;
7 | import com.sap.olingo.jpa.metadata.core.edm.mapper.extension.ODataAction;
8 | import com.sap.olingo.jpa.processor.core.testmodel.Person;
9 |
10 | public class ExampleJavaOneAction implements ODataAction {
11 |
12 | @EdmAction(isBound = false)
13 | public void unbound(
14 | @EdmParameter(name = "Person") Person person,
15 | @EdmParameter(name = "A", precision = 34, scale = 10) BigDecimal a) {
16 | // Do nothing
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/serializer/JPAOperationSerializer.java:
--------------------------------------------------------------------------------
1 | package com.sap.olingo.jpa.processor.core.serializer;
2 |
3 | import org.apache.olingo.commons.api.data.Annotatable;
4 | import org.apache.olingo.commons.api.edm.EdmType;
5 | import org.apache.olingo.server.api.ODataRequest;
6 | import org.apache.olingo.server.api.serializer.SerializerException;
7 | import org.apache.olingo.server.api.serializer.SerializerResult;
8 |
9 | import com.sap.olingo.jpa.processor.core.exception.ODataJPASerializerException;
10 |
11 | public interface JPAOperationSerializer extends JPASerializer {
12 | public SerializerResult serialize(final Annotatable result, final EdmType entityType, final ODataRequest request)
13 | throws SerializerException, ODataJPASerializerException;
14 | }
15 |
--------------------------------------------------------------------------------
/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/uri/JPALevelsExpandOption.java:
--------------------------------------------------------------------------------
1 | package com.sap.olingo.jpa.processor.core.uri;
2 |
3 | import org.apache.olingo.server.api.uri.queryoption.LevelsExpandOption;
4 |
5 | class JPALevelsExpandOption implements LevelsExpandOption {
6 |
7 | private final boolean isMax;
8 | private int value = 0;
9 |
10 | JPALevelsExpandOption(final LevelsExpandOption levelsOption) {
11 | this.isMax = levelsOption.isMax();
12 | this.value = levelsOption.getValue();
13 | }
14 |
15 | @Override
16 | public boolean isMax() {
17 | return isMax;
18 | }
19 |
20 | @Override
21 | public int getValue() {
22 | return value;
23 | }
24 |
25 | LevelsExpandOption levelResolved() {
26 | if (value > 0)
27 | value -= 1;
28 | return this;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/InheritanceByJoinSavingAccount.java:
--------------------------------------------------------------------------------
1 | package com.sap.olingo.jpa.processor.core.testmodel;
2 |
3 | import java.math.BigDecimal;
4 |
5 | import jakarta.persistence.Column;
6 | import jakarta.persistence.DiscriminatorValue;
7 | import jakarta.persistence.Entity;
8 | import jakarta.persistence.PrimaryKeyJoinColumn;
9 | import jakarta.persistence.Table;
10 |
11 | @DiscriminatorValue("SavingAccount")
12 | @Entity(name = "InheritanceSavingAccount")
13 | @Table(schema = "\"OLINGO\"", name = "\"InheritanceByJoinSavingAccount\"")
14 | @PrimaryKeyJoinColumn(name = "\"ID\"")
15 | public class InheritanceByJoinSavingAccount extends InheritanceByJoinAccount {
16 |
17 | @Column(name = "\"InterestRate\"", precision = 5, scale = 2)
18 | private BigDecimal interestRate;
19 | }
20 |
--------------------------------------------------------------------------------
/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPARequestLink.java:
--------------------------------------------------------------------------------
1 | package com.sap.olingo.jpa.processor.core.processor;
2 |
3 | import java.util.Map;
4 |
5 | import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAEntityType;
6 | import com.sap.olingo.jpa.processor.core.exception.ODataJPAProcessorException;
7 |
8 | public interface JPARequestLink {
9 | /**
10 | * Provides an instance of the target entity metadata
11 | * @return
12 | */
13 | public JPAEntityType getEntityType();
14 |
15 | /**
16 | * Map of related keys
17 | * @return
18 | * @throws ODataJPAProcessorException
19 | */
20 | public Map getRelatedKeys() throws ODataJPAProcessorException;
21 |
22 | public Map getValues() throws ODataJPAProcessorException;
23 | }
24 |
--------------------------------------------------------------------------------
/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/DummyEmbeddedToIgnore.java:
--------------------------------------------------------------------------------
1 | package com.sap.olingo.jpa.processor.core.testmodel;
2 |
3 | import java.sql.Blob;
4 | import java.sql.Clob;
5 |
6 | import jakarta.persistence.Basic;
7 | import jakarta.persistence.Column;
8 | import jakarta.persistence.Embeddable;
9 | import jakarta.persistence.FetchType;
10 | import jakarta.persistence.Lob;
11 |
12 | import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmIgnore;
13 |
14 | @EdmIgnore
15 | @Embeddable
16 | public class DummyEmbeddedToIgnore {
17 |
18 | @Lob
19 | @Column(name = "\"Command\"")
20 | @Basic(fetch = FetchType.LAZY)
21 | private Clob command;
22 |
23 | @Lob
24 | @Column(name = "\"LargeBytes\"")
25 | @Basic(fetch = FetchType.LAZY)
26 | private Blob largeBytes;
27 | }
28 |
--------------------------------------------------------------------------------
/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/JoinComplex.java:
--------------------------------------------------------------------------------
1 | package com.sap.olingo.jpa.processor.core.testmodel;
2 |
3 | import java.util.List;
4 |
5 | import jakarta.persistence.Column;
6 | import jakarta.persistence.Embeddable;
7 | import jakarta.persistence.JoinColumn;
8 | import jakarta.persistence.JoinTable;
9 | import jakarta.persistence.OneToMany;
10 |
11 | @Embeddable
12 | public class JoinComplex {
13 |
14 | @Column(name = "\"Number\"")
15 | private Long number;
16 |
17 | @OneToMany
18 | @JoinTable(name = "\"JoinRelation\"", schema = "\"OLINGO\"",
19 | joinColumns = @JoinColumn(name = "\"SourceID\"", referencedColumnName = "\"SourceKey\""),
20 | inverseJoinColumns = @JoinColumn(name = "\"TargetID\""))
21 | private List oneToManyComplex;
22 | }
23 |
--------------------------------------------------------------------------------
/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/api/JPAInheritanceInformation.java:
--------------------------------------------------------------------------------
1 | package com.sap.olingo.jpa.metadata.core.edm.mapper.api;
2 |
3 | import java.util.List;
4 |
5 | import com.sap.olingo.jpa.metadata.core.edm.mapper.exception.ODataJPAModelException;
6 |
7 | /**
8 | *
9 | *
10 | *
11 | * 2025-10-21
12 | *
13 | */
14 | public interface JPAInheritanceInformation {
15 | default JPAInheritanceType getInheritanceType() {
16 | return JPAInheritanceType.NON;
17 | }
18 |
19 | /**
20 | *
21 | * @return The join condition in case of inheritance by join
22 | * @throws ODataJPAModelException
23 | */
24 | List getJoinColumnsList() throws ODataJPAModelException;
25 |
26 | List getReversedJoinColumnsList() throws ODataJPAModelException;
27 | }
28 |
--------------------------------------------------------------------------------
/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/testobjects/ConverterWithConstructorError.java:
--------------------------------------------------------------------------------
1 | package com.sap.olingo.jpa.metadata.core.edm.mapper.testobjects;
2 |
3 | import jakarta.persistence.AttributeConverter;
4 |
5 | public class ConverterWithConstructorError implements AttributeConverter[], Integer> {
6 |
7 | private final int counter;
8 |
9 | public ConverterWithConstructorError(final int counter) {
10 | super();
11 | this.counter = counter;
12 | }
13 |
14 | @Override
15 | public Integer convertToDatabaseColumn(final Enum>[] attribute) {
16 | return null;
17 | }
18 |
19 | @Override
20 | public Enum>[] convertToEntityAttribute(final Integer dbData) {
21 | return null;
22 | }
23 |
24 | public int getCounter() {
25 | return counter;
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/jpa/odata-jpa-odata-vocabularies/src/main/java/com/sap/olingo/jpa/metadata/odata/v4/capabilities/terms/DeleteRestrictionsProperties.java:
--------------------------------------------------------------------------------
1 | package com.sap.olingo.jpa.metadata.odata.v4.capabilities.terms;
2 |
3 | import com.sap.olingo.jpa.metadata.core.edm.extension.vocabularies.PropertyAccess;
4 |
5 | public enum DeleteRestrictionsProperties implements PropertyAccess {
6 |
7 | DELETABLE("Deletable"),
8 | NON_DELETABLE_NAVIGATION_PROPERTIES("NonDeletableNavigationProperties"),
9 | MAX_LEVELS("MaxLevels"),
10 | DESCRIPTION("Description"),
11 | LONG_DESCRIPTION("LongDescription");
12 |
13 | private final String property;
14 |
15 | private DeleteRestrictionsProperties(final String property) {
16 | this.property = property;
17 | }
18 |
19 | @Override
20 | public String property() {
21 | return property;
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/exception/ODataJPAKeyPairException.java:
--------------------------------------------------------------------------------
1 | package com.sap.olingo.jpa.processor.core.exception;
2 |
3 | import static org.apache.olingo.commons.api.http.HttpStatusCode.INTERNAL_SERVER_ERROR;
4 |
5 | public class ODataJPAKeyPairException extends ODataJPAProcessException {
6 |
7 | private static final long serialVersionUID = 6006099025067551818L;
8 | private static final String BUNDLE_NAME = "processor-exceptions-i18n";
9 | private static final String MESSAGE_KEY = "KEY_PAIR_CONVERSION_ERROR";
10 |
11 | public ODataJPAKeyPairException(final Throwable cause, final String... params) {
12 | super(MESSAGE_KEY, INTERNAL_SERVER_ERROR, cause, params);
13 | }
14 |
15 | @Override
16 | protected String getBundleName() {
17 | return BUNDLE_NAME;
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/MissingCardinalityAnnotation.java:
--------------------------------------------------------------------------------
1 | package com.sap.olingo.jpa.processor.core.errormodel;
2 |
3 | import java.util.List;
4 |
5 | import jakarta.persistence.Column;
6 | import jakarta.persistence.Entity;
7 | import jakarta.persistence.Id;
8 | import jakarta.persistence.JoinColumn;
9 | import jakarta.persistence.JoinTable;
10 |
11 | @Entity()
12 | public class MissingCardinalityAnnotation {
13 |
14 | @Id
15 | @Column(name = "\"ID\"")
16 | protected String id;
17 |
18 | @JoinTable(name = "\"Membership\"", schema = "\"OLINGO\"",
19 | joinColumns = @JoinColumn(name = "\"PersonID\""),
20 | inverseJoinColumns = @JoinColumn(name = "\"TeamID\""))
21 | private List teams;
22 |
23 | @JoinColumn(name = "\"TeamKey\"")
24 | private Team oneTeam;
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AssociationOneToOneTarget.java:
--------------------------------------------------------------------------------
1 | package com.sap.olingo.jpa.processor.core.testmodel;
2 |
3 | import jakarta.persistence.Column;
4 | import jakarta.persistence.Entity;
5 | import jakarta.persistence.FetchType;
6 | import jakarta.persistence.Id;
7 | import jakarta.persistence.OneToOne;
8 | import jakarta.persistence.Table;
9 |
10 | @Entity(name = "AssociationOneToOneTarget")
11 | @Table(schema = "\"OLINGO\"", name = "\"AssociationOneToOneTarget\"")
12 | public class AssociationOneToOneTarget {
13 |
14 | @Id
15 | @Column(name = "\"ID\"")
16 | protected String iD;
17 |
18 | @Column(name = "\"SOURCE\"")
19 | protected String source;
20 |
21 | @OneToOne(mappedBy = "defaultTarget", fetch = FetchType.LAZY)
22 | private AssociationOneToOneSource defaultSource;
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/extension/IntermediateEntitySetAccess.java:
--------------------------------------------------------------------------------
1 | package com.sap.olingo.jpa.metadata.core.edm.mapper.extension;
2 |
3 | import java.util.List;
4 |
5 | import org.apache.olingo.commons.api.edm.provider.CsdlAnnotation;
6 |
7 | import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAElement;
8 |
9 | public interface IntermediateEntitySetAccess extends JPAElement {
10 | /**
11 | * Enables to add or overwrite annotations to an entity set, e.g. because the type of annotation is not enabled via
12 | * {@link com.sap.olingo.jpa.metadata.core.edm.annotation.EdmAnnotation EdmAnnotation} or they should be changed
13 | * during runtime.
14 | * @param annotations
15 | */
16 | public void addAnnotations(final List annotations);
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/TeamWithTransientError.java:
--------------------------------------------------------------------------------
1 | package com.sap.olingo.jpa.processor.core.errormodel;
2 |
3 | import jakarta.persistence.Column;
4 | import jakarta.persistence.Entity;
5 | import jakarta.persistence.Id;
6 | import jakarta.persistence.Table;
7 |
8 | import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmTransient;
9 |
10 | @Entity(name = "TeamWithTransientError")
11 | @Table(schema = "\"OLINGO\"", name = "\"Team\"")
12 | public class TeamWithTransientError {
13 |
14 | @Id
15 | @Column(name = "\"TeamKey\"")
16 | private String iD;
17 |
18 | @Column(name = "\"Name\"")
19 | private String name;
20 |
21 | @EdmTransient(requiredAttributes = { "name", "unknown" }, calculator = DummyPropertyCalculator.class)
22 | private String completeName;
23 | }
24 |
--------------------------------------------------------------------------------
/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/UUIDToStringConverter.java:
--------------------------------------------------------------------------------
1 | package com.sap.olingo.jpa.processor.core.testmodel;
2 |
3 | import java.util.UUID;
4 |
5 | import jakarta.persistence.AttributeConverter;
6 | import jakarta.persistence.Converter;
7 |
8 | /**
9 | * Default converter to convert from {@link java.util.UUID} to a byte array.
10 | *
11 | * @author Oliver Grande
12 | */
13 | @Converter(autoApply = false)
14 | public class UUIDToStringConverter implements AttributeConverter {
15 |
16 | @Override
17 | public String convertToDatabaseColumn(final UUID uuid) {
18 | return uuid == null ? null : uuid.toString();
19 | }
20 |
21 | @Override
22 | public UUID convertToEntityAttribute(final String dbData) {
23 | return dbData == null ? null : UUID.fromString(dbData);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/EmbeddedKeyPartOfGroup.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package com.sap.olingo.jpa.processor.core.errormodel;
5 |
6 | import jakarta.persistence.Column;
7 | import jakarta.persistence.EmbeddedId;
8 | import jakarta.persistence.Entity;
9 | import jakarta.persistence.Version;
10 |
11 | import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmVisibleFor;
12 | import com.sap.olingo.jpa.processor.core.testmodel.CountryKey;
13 |
14 | /**
15 | * @author Oliver Grande
16 | * Created: 29.06.2019
17 | *
18 | */
19 | @Entity
20 | public class EmbeddedKeyPartOfGroup {
21 |
22 | @EdmVisibleFor("Person")
23 | @EmbeddedId
24 | private CountryKey key;
25 |
26 | @Version
27 | @Column(name = "\"ETag\"", nullable = false)
28 | protected long eTag;
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/DateConverter.java:
--------------------------------------------------------------------------------
1 | package com.sap.olingo.jpa.processor.core.testmodel;
2 |
3 | import java.sql.Date;
4 | import java.time.LocalDate;
5 |
6 | import jakarta.persistence.AttributeConverter;
7 | import jakarta.persistence.Converter;
8 |
9 | //This converter has to be mentioned at all columns it is applicable
10 | @Converter(autoApply = false)
11 | public class DateConverter implements AttributeConverter {
12 |
13 | @Override
14 | public Date convertToDatabaseColumn(final LocalDate locDate) {
15 | return (locDate == null ? null : Date.valueOf(locDate));
16 | }
17 |
18 | @Override
19 | public LocalDate convertToEntityAttribute(final Date sqlDate) {
20 | return (sqlDate == null ? null : sqlDate.toLocalDate());
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataClaimProvider.java:
--------------------------------------------------------------------------------
1 | package com.sap.olingo.jpa.processor.core.api;
2 |
3 | import java.util.List;
4 | import java.util.Optional;
5 |
6 | import javax.annotation.Nonnull;
7 |
8 | /**
9 | * Container that provides claims
10 | *
11 | * @author Oliver Grande
12 | * Created: 30.06.2019
13 | *
14 | */
15 | public interface JPAODataClaimProvider {
16 | /**
17 | * @param attributeName
18 | * @return Provides a list claim values for a given attribute.
19 | */
20 | @Nonnull
21 | List> get(final String attributeName); // NOSONAR
22 |
23 | /**
24 | *
25 | * @return An optional that may contain the user id for the current request
26 | */
27 | default Optional user() {
28 | return Optional.empty();
29 | }
30 | }
--------------------------------------------------------------------------------
/.github/workflows/archetype.yml:
--------------------------------------------------------------------------------
1 | name: Build Archetype
2 | on:
3 | push:
4 | branches:
5 | - main
6 | pull_request:
7 | types: [opened, synchronize, reopened]
8 | jobs:
9 | build:
10 | runs-on: ubuntu-latest
11 | strategy:
12 | matrix:
13 | java-version: [ 17 ]
14 | name: Archetype with Java ${{ matrix.java-version }}
15 | steps:
16 | - uses: actions/checkout@v6
17 | - name: Set up JDK ${{ matrix.java-version }}
18 | uses: actions/setup-java@v5
19 | with:
20 | java-version: ${{ matrix.java-version }}
21 | distribution: 'temurin'
22 | cache: maven
23 | - name: 1. Build JPA
24 | run: cd ./jpa && mvn clean install -Dmaven.test.skip
25 | - name: 2. Build and test archetype
26 | run: cd ./jpa-archetype && mvn clean install archetype:integration-test
27 |
--------------------------------------------------------------------------------
/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/SqlJoinTypeTest.java:
--------------------------------------------------------------------------------
1 | package com.sap.olingo.jpa.processor.cb.impl;
2 |
3 | import static org.junit.jupiter.api.Assertions.assertEquals;
4 |
5 | import jakarta.persistence.criteria.JoinType;
6 |
7 | import org.junit.jupiter.api.Test;
8 |
9 | class SqlJoinTypeTest {
10 |
11 | @Test
12 | void testGetJoinTypeReturnsValue() {
13 | assertEquals(JoinType.INNER, SqlJoinType.INNER.getJoinType());
14 | assertEquals(JoinType.LEFT, SqlJoinType.LEFT.getJoinType());
15 | assertEquals(JoinType.RIGHT, SqlJoinType.RIGHT.getJoinType());
16 | }
17 |
18 | @Test
19 | void testByJoinType() {
20 | assertEquals(SqlJoinType.INNER, SqlJoinType.byJoinType(JoinType.INNER));
21 | assertEquals(SqlJoinType.INNER, SqlJoinType.byJoinType(JoinType.INNER));
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/converter/JPARowConverter.java:
--------------------------------------------------------------------------------
1 | package com.sap.olingo.jpa.processor.core.converter;
2 |
3 | import java.util.Collection;
4 | import java.util.List;
5 |
6 | import jakarta.persistence.Tuple;
7 |
8 | import org.apache.olingo.commons.api.data.Entity;
9 | import org.apache.olingo.server.api.ODataApplicationException;
10 |
11 | import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAEntityType;
12 | import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAPath;
13 | import com.sap.olingo.jpa.processor.core.api.JPAODataPageExpandInfo;
14 |
15 | public interface JPARowConverter {
16 |
17 | Entity convertRow(JPAEntityType rowEntity, Tuple row, Collection requestedSelection,
18 | List expandInfo, JPAExpandResult jpaResult) throws ODataApplicationException;
19 |
20 | }
--------------------------------------------------------------------------------
/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/ExampleJavaOneFunction.java:
--------------------------------------------------------------------------------
1 | package com.sap.olingo.jpa.metadata.core.edm.mapper.impl;
2 |
3 | import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmFunction;
4 | import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmFunction.ReturnType;
5 | import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmParameter;
6 | import com.sap.olingo.jpa.metadata.core.edm.mapper.extension.ODataFunction;
7 |
8 | public class ExampleJavaOneFunction implements ODataFunction {
9 |
10 | public ExampleJavaOneFunction() {
11 | super();
12 | }
13 |
14 | @EdmFunction(name = "", returnType = @ReturnType, hasFunctionImport = true)
15 | public Integer sum(
16 | @EdmParameter(name = "A") final short a, @EdmParameter(name = "B") final int b) {
17 | return a + b;
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/exception/ODataJPANotImplementedException.java:
--------------------------------------------------------------------------------
1 | package com.sap.olingo.jpa.processor.core.exception;
2 |
3 | import static org.apache.olingo.commons.api.http.HttpStatusCode.NOT_IMPLEMENTED;
4 |
5 | /*
6 | * This exception is thrown when an exception occurs in a jpa pojo method
7 | */
8 | public class ODataJPANotImplementedException extends ODataJPAProcessException { // NOSONAR
9 |
10 | private static final long serialVersionUID = 2410838419178517426L;
11 | private static final String BUNDLE_NAME = "processor-exceptions-i18n";
12 |
13 | public ODataJPANotImplementedException(final String... params) {
14 | super(NOT_IMPLEMENTED.name(), NOT_IMPLEMENTED, params);
15 | }
16 |
17 | @Override
18 | protected String getBundleName() {
19 | return BUNDLE_NAME;
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/jpa/odata-jpa-vocabularies/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/vocabularies/Member.java:
--------------------------------------------------------------------------------
1 | package com.sap.olingo.jpa.metadata.core.edm.mapper.vocabularies;
2 |
3 | import org.apache.olingo.commons.api.edm.provider.CsdlEnumMember;
4 |
5 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
6 | import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
7 |
8 | @JsonIgnoreProperties(ignoreUnknown = true)
9 | public class Member extends CsdlEnumMember {
10 |
11 | @Override
12 | @JacksonXmlProperty(localName = "Name", isAttribute = true)
13 | public CsdlEnumMember setName(final String name) {
14 | return super.setName(name);
15 | }
16 |
17 | @Override
18 | @JacksonXmlProperty(localName = "Value", isAttribute = true)
19 | public CsdlEnumMember setValue(final String value) {
20 | return super.setValue(value);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/testobjects/ExampleJavaOneFunction.java:
--------------------------------------------------------------------------------
1 | package com.sap.olingo.jpa.metadata.core.edm.mapper.testobjects;
2 |
3 | import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmFunction;
4 | import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmFunction.ReturnType;
5 | import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmParameter;
6 | import com.sap.olingo.jpa.metadata.core.edm.mapper.extension.ODataFunction;
7 |
8 | public class ExampleJavaOneFunction implements ODataFunction {
9 |
10 | public ExampleJavaOneFunction() {
11 | super();
12 | }
13 |
14 | @EdmFunction(returnType = @ReturnType, hasFunctionImport = true)
15 | public Integer sum(
16 | @EdmParameter(name = "A") final short a, @EdmParameter(name = "B") final int b) {
17 | return a + b;
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/TeamWithTransientCalculatorError.java:
--------------------------------------------------------------------------------
1 | package com.sap.olingo.jpa.processor.core.errormodel;
2 |
3 | import jakarta.persistence.Column;
4 | import jakarta.persistence.Entity;
5 | import jakarta.persistence.Id;
6 | import jakarta.persistence.Table;
7 |
8 | import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmTransient;
9 |
10 | @Entity(name = "TeamWithTransientCalculatorError")
11 | @Table(schema = "\"OLINGO\"", name = "\"Team\"")
12 | public class TeamWithTransientCalculatorError {
13 |
14 | @Id
15 | @Column(name = "\"TeamKey\"")
16 | private String iD;
17 |
18 | @Column(name = "\"Name\"")
19 | private String name;
20 |
21 | @EdmTransient(requiredAttributes = { "name" }, calculator = TransientPropertyCalculatorTwoConstructors.class)
22 | private String completeName;
23 | }
24 |
--------------------------------------------------------------------------------
/jpa/odata-jpa-vocabularies/src/main/java/com/sap/olingo/jpa/metadata/core/edm/extension/vocabularies/ReferenceAccess.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package com.sap.olingo.jpa.metadata.core.edm.extension.vocabularies;
5 |
6 | /**
7 | * @author Oliver Grande
8 | * @since 1.1.1
9 | * 13.02.2023
10 | */
11 | public interface ReferenceAccess {
12 |
13 | /**
14 | * See: 3.4
17 | * Element edmx:Include
18 | * @param namespace Namespace of a schema defined in the referenced CSDL document to be included. The same namespace
19 | * MUST NOT be included more than once.
20 | * @param alias Alias for the given namespace. The alias must be unique.
21 | */
22 | void addInclude(String namespace, String alias);
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/jpa/odata-jpa-vocabularies/src/main/java/com/sap/olingo/jpa/metadata/core/edm/extension/vocabularies/JPAReferences.java:
--------------------------------------------------------------------------------
1 | package com.sap.olingo.jpa.metadata.core.edm.extension.vocabularies;
2 |
3 | import java.util.List;
4 | import java.util.Optional;
5 |
6 | import javax.annotation.Nonnull;
7 |
8 | import org.apache.olingo.commons.api.edm.FullQualifiedName;
9 | import org.apache.olingo.commons.api.edm.provider.CsdlNamed;
10 | import org.apache.olingo.commons.api.edm.provider.CsdlTerm;
11 |
12 | public interface JPAReferences {
13 |
14 | public String convertAlias(@Nonnull final String alias);
15 |
16 | public Optional getTerm(@Nonnull final FullQualifiedName termName);
17 |
18 | public Optional getType(@Nonnull final FullQualifiedName fqn);
19 |
20 | public List getTerms(@Nonnull String schemaAlias, @Nonnull Applicability appliesTo);
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/extension/IntermediateNavigationPropertyAccess.java:
--------------------------------------------------------------------------------
1 | package com.sap.olingo.jpa.metadata.core.edm.mapper.extension;
2 |
3 | import java.util.List;
4 |
5 | import org.apache.olingo.commons.api.edm.provider.CsdlAnnotation;
6 | import org.apache.olingo.commons.api.edm.provider.CsdlOnDelete;
7 |
8 | public interface IntermediateNavigationPropertyAccess extends IntermediateModelItemAccess {
9 | public void setOnDelete(CsdlOnDelete onDelete);
10 |
11 | /**
12 | * Enables to add annotations to a navigation property, e.g. because the type of annotation is not enabled via
13 | * {@link com.sap.olingo.jpa.metadata.core.edm.annotation.EdmAnnotation EdmAnnotation} or should be changed during
14 | * runtime
15 | * @param annotations
16 | */
17 | public void addAnnotations(final List annotations);
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/jpa/odata-jpa-test/src/test/java/com/sap/olingo/jpa/processor/test/AbstractConverterTest.java:
--------------------------------------------------------------------------------
1 | package com.sap.olingo.jpa.processor.test;
2 |
3 | import static org.junit.jupiter.api.Assertions.assertEquals;
4 | import static org.junit.jupiter.api.Assertions.assertNull;
5 |
6 | import jakarta.persistence.AttributeConverter;
7 |
8 | import org.junit.jupiter.api.Test;
9 |
10 | abstract class AbstractConverterTest {
11 | protected AttributeConverter cut;
12 | protected E exp;
13 |
14 | @Test
15 | void testConversion() {
16 | assertEquals(exp, cut.convertToEntityAttribute(cut.convertToDatabaseColumn(exp)));
17 | }
18 |
19 | @Test
20 | void testToDatabaseReturnsNullOnNull() {
21 | assertNull(cut.convertToDatabaseColumn(null));
22 | }
23 |
24 | @Test
25 | void testToEntityAttributeReturnsNullOnNull() {
26 | assertNull(cut.convertToEntityAttribute(null));
27 | }
28 |
29 | }
--------------------------------------------------------------------------------
/jpa/odata-jpa-vocabularies/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/vocabularies/EdmxReferenceInclude.java:
--------------------------------------------------------------------------------
1 | package com.sap.olingo.jpa.metadata.core.edm.mapper.vocabularies;
2 |
3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4 | import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
5 | import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
6 |
7 | @JsonIgnoreProperties(ignoreUnknown = true)
8 | @JacksonXmlRootElement(localName = "Reference", namespace = "edmx")
9 | public class EdmxReferenceInclude {
10 |
11 | @JacksonXmlProperty(localName = "Namespace")
12 | private String namespace;
13 |
14 | @JacksonXmlProperty(localName = "Alias")
15 | private String alias;
16 |
17 | public String getNamespace() {
18 | return namespace;
19 | }
20 |
21 | public String getAlias() {
22 | return alias;
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/testobjects/HeaderParamTransientPropertyConverter.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package com.sap.olingo.jpa.processor.core.testobjects;
5 |
6 | import java.util.List;
7 | import java.util.Map;
8 |
9 | import com.sap.olingo.jpa.metadata.api.JPAHttpHeaderMap;
10 | import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmTransientPropertyCalculator;
11 |
12 | /**
13 | * @author Oliver Grande
14 | * Created: 17.03.2020
15 | *
16 | */
17 | public class HeaderParamTransientPropertyConverter implements EdmTransientPropertyCalculator {
18 | private final JPAHttpHeaderMap header;
19 |
20 | public HeaderParamTransientPropertyConverter(final JPAHttpHeaderMap header) {
21 | super();
22 | this.header = header;
23 | }
24 |
25 | public Map> getHeader() {
26 | return header;
27 | }
28 | }
--------------------------------------------------------------------------------
/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/TeamWithTransientCalculatorConstructorError.java:
--------------------------------------------------------------------------------
1 | package com.sap.olingo.jpa.processor.core.errormodel;
2 |
3 | import jakarta.persistence.Column;
4 | import jakarta.persistence.Entity;
5 | import jakarta.persistence.Id;
6 | import jakarta.persistence.Table;
7 |
8 | import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmTransient;
9 |
10 | @Entity(name = "TeamWithTransientConstructorError")
11 | @Table(schema = "\"OLINGO\"", name = "\"Team\"")
12 | public class TeamWithTransientCalculatorConstructorError {
13 |
14 | @Id
15 | @Column(name = "\"TeamKey\"")
16 | private String iD;
17 |
18 | @Column(name = "\"Name\"")
19 | private String name;
20 |
21 | @EdmTransient(requiredAttributes = { "name" }, calculator = TransientPropertyCalculatorWrongConstructor.class)
22 | private String completeName;
23 | }
24 |
--------------------------------------------------------------------------------
/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/JoinTarget.java:
--------------------------------------------------------------------------------
1 | package com.sap.olingo.jpa.processor.core.testmodel;
2 |
3 | import jakarta.persistence.Column;
4 | import jakarta.persistence.Entity;
5 | import jakarta.persistence.Id;
6 | import jakarta.persistence.JoinColumn;
7 | import jakarta.persistence.JoinTable;
8 | import jakarta.persistence.ManyToOne;
9 | import jakarta.persistence.Table;
10 |
11 | @Entity(name = "JoinTarget")
12 | @Table(schema = "\"OLINGO\"", name = "\"JoinTarget\"")
13 | public class JoinTarget {
14 | @Id
15 | @Column(name = "\"TargetKey\"")
16 | private Integer targetID;
17 |
18 | @ManyToOne()
19 | @JoinTable(name = "\"JoinRelation\"", schema = "\"OLINGO\"",
20 | joinColumns = @JoinColumn(name = "\"TargetID\""),
21 | inverseJoinColumns = @JoinColumn(name = "\"SourceID\""))
22 | private JoinSource manyToOne;
23 | }
24 |
--------------------------------------------------------------------------------
/jpa/odata-jpa-annotation/src/main/java/com/sap/olingo/jpa/metadata/core/edm/annotation/EdmMediaStream.java:
--------------------------------------------------------------------------------
1 | package com.sap.olingo.jpa.metadata.core.edm.annotation;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | /**
9 | * Marks an attribute as one that is a data stream. Two options are given to describe the content. Either static as
10 | * string (contentType) or dynamically in another attribute (contentTypeAttribute). Exactly on has to be given.
11 | * @author Oliver Grande
12 | *
13 | */
14 | @Target({ ElementType.FIELD })
15 | @Retention(value = RetentionPolicy.RUNTIME)
16 | public @interface EdmMediaStream {
17 | boolean stream() default true;
18 |
19 | String contentType() default "";
20 |
21 | String contentTypeAttribute() default "";
22 | }
23 |
--------------------------------------------------------------------------------