Skip to content

ousatov-ua/Olingo4-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

89 Commits
 
 
 
 
 
 

Repository files navigation

Olingo4 server

Tomcat config

Please edit /conf/context.xml in Tomcat home directory and add Database pool:

<Resource name="jdbc/nnmrlsDb" auth="Container" type="javax.sql.DataSource"
          maxTotal="25" maxIdle="5" maxWaitMillis="5000"
          username="user" password="password" driverClassName="com.mysql.cj.jdbc.Driver"
          url="jdbc:mysql:https://server:3306/schema"/>

Additionally, you will need to add that driver lib to $APACHE_HOME/lib

Next is added to catalina.sh to have tomcat running on IP V4:

JAVA_OPTS="$JAVA_OPTS -Djava.net.preferIPv4Stack=true -Djava.net.preferIPv4Addresses=true "

right before sentence:

JAVA_OPTS="$JAVA_OPTS $JSSE_OPTS"

Also, in server.xml connector is configured to have next attributes:

<Connector port="8080"

           address="0.0.0.0"
           useIPVHosts="true"/>

Functional tests

Currently, we are using embedded DB. It needs ncurses lib installed (maybe)

For [email protected]:

sudo apt-get install libncurses5

For Fedora@38:

sudo dnf install libnsl
sudo dnf install ncurses-compat-libs

Test coverage

You can check html page generated by Jacoco during build. It is in /target/site/jacoco-ut/index.html.

So mvn clean install will give generated report.

Generation of code

- !!! Please pay attention !!!

The code for *CsdlEntityTypeProvider is generated using com.olus.olingo2.nmrls.util.DdlUtil

Mapping new fields/tables

- !!! Please pay attention !!!

Currently, all CsdlEntityTypes have properties with the same name as database columns

This is very important because all queries are generated based on those properties.

You'll need to implement mapper if you need custom mappings between CsdlEntityType and Database columns

New table

  1. Add appropriate ET_<name>_NAME, ET_<name>_FQN, ES_<name>_NAME in NnmrlsEdmProvider
  2. Put those in ALL_ET, ALL_FQN, ALL_ES (in NnmrlsEdmProvider)
  3. Get DDL of your new table (just use generate SQL tool if you have just a table without its creation script)
  4. Use com.olus.olingo4.nmrls.util.DdlUtil to generate java code for all columns
  5. Create CsdlEntityTypeProvider - refer to existing ones as example. Put generated java code inside it.
  6. Put call to your CsdlEntityProvider from NnmrlsEdmProvider.getCsdlEntityType

Add fields to a table

  1. Update appropriate CsdlEntityTypeProvider.

Olingo4 operations

Get one property only

Optimized in db terms too. So only specific column will be fetched on DB level

http:https://localhost:8080/.../OfficeData('1')/OfficeAddress1

Top and Skip

Optimized in db terms too. So pagination will work on db side as well.

http:https://localhost:8080/.../OfficeData?$top=5&$skip=1

Select

Select is optimized in db terms too. So only specific columns will be fetched on DB level.

http:https://localhost:8080/.../OfficeData('1')?$select=OfficeAddress1,OfficeAddress2

Filter

Next current filter operations are supported

Comparison operators

http:https://localhost:8080/.../PropertyDataLocation?$filter=ListingId eq 1

http:https://localhost:8080/.../PropertyDataLocation?$filter=ListingId ne 1

http:https://localhost:8080/.../PropertyDataLocation?$filter=ListingId gt 2

http:https://localhost:8080/.../PropertyDataLocation?$filter=ListingId ge 2

http:https://localhost:8080/.../PropertyDataLocation?$filter=ListingId le 2

http:https://localhost:8080/.../PropertyDataLocation?$filter=ListingId lt 2

Unary operators

http:https://localhost:8080/.../PropertyDataLocation?$filter=-ListingId eq -1

http:https://localhost:8080/.../PropertyDataLocation?$filter=not (ListingId eq 42)

Method calls and strong binding unary not

http:https://localhost:8080/.../PropertyDataLocation?$filter=contains(UnparsedAddress,'ROSECREST DRIVE')

http:https://localhost:8080/.../PropertyDataLocation?$filter=not contains(UnparsedAddress,'ROSECREST DRIVE')

Arithmetic operators

http:https://localhost:8080/.../PropertyDataLocation?$filter=ListingId add 1 eq 2

http:https://localhost:8080/.../PropertyDataLocation?$filter=ListingId sub 1 eq 1

http:https://localhost:8080/.../PropertyDataLocation?$filter=ListingId div 2 eq 1

http:https://localhost:8080/.../PropertyDataLocation?$filter=ListingId mul 2 eq 6

http:https://localhost:8080/.../PropertyDataLocation?$filter=ListingId mod 2 eq 1

String literal

http:https://localhost:8080/.../PropertyDataLocation?$filter=UnparsedAddress eq '000 ROSECREST DRIVE 1'

Boolean operators

http:https://localhost:8080/.../PropertyDataLocation?$filter=contains(UnparsedAddress,'ROSECREST DRIVE 1') or ListingId eq 1

http:https://localhost:8080/.../PropertyDataLocation?$filter=contains(UnparsedAddress,'ROSECREST DRIVE 1') and ListingId eq 1

http:https://localhost:8080/.../PropertyDataLocation?$filter=contains(UnparsedAddress,'ROSECREST DRIVE 1') and ListingId eq 3

OAUTH2

Currently, oauth2 implemented (grant_type=client_credentials)

Please take a look into config.json in /resources/. Cache for tokens is Guava Cache.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages