16
CUSTOMER Riley B Rainey Cloud Architect, Global SAP Cloud Platform Team Olingo Unleashed using Olingo JPA for prototyping and production SAP Cloud Platform

Olingo Unleashed using Olingo JPA for prototyping and ... · CUSTOMER Riley B Rainey Cloud Architect, Global SAP Cloud Platform Team Olingo Unleashed –using Olingo JPA for prototyping

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Olingo Unleashed using Olingo JPA for prototyping and ... · CUSTOMER Riley B Rainey Cloud Architect, Global SAP Cloud Platform Team Olingo Unleashed –using Olingo JPA for prototyping

CUSTOMER

Riley B Rainey

Cloud Architect, Global SAP Cloud Platform Team

Olingo Unleashed – using Olingo JPA for prototyping and production SAP Cloud Platform

Page 2: Olingo Unleashed using Olingo JPA for prototyping and ... · CUSTOMER Riley B Rainey Cloud Architect, Global SAP Cloud Platform Team Olingo Unleashed –using Olingo JPA for prototyping

2CUSTOMER© 2017 SAP SE or an SAP affiliate company. All rights reserved. ǀ

The information in this presentation is confidential and proprietary to SAP and may not be disclosed without the

permission of SAP. This presentation is not subject to your license agreement or any other service or subscription

agreement with SAP. SAP has no obligation to pursue any course of business outlined in this document or any related

presentation, or to develop or release any functionality mentioned therein. This document, or any related presentation

and SAP's strategy and possible future developments, products and or platforms directions and functionality are all

subject to change and may be changed by SAP at any time for any reason without notice. The information in this

document is not a commitment, promise or legal obligation to deliver any material, code or functionality. This

document is provided without a warranty of any kind, either express or implied, including but not limited to, the implied

warranties of merchantability, fitness for a particular purpose, or non-infringement. This document is for informational

purposes and may not be incorporated into a contract. SAP assumes no responsibility for errors or omissions in this

document, except if such damages were caused by SAP´s willful misconduct or gross negligence.

All forward-looking statements are subject to various risks and uncertainties that could cause actual results to differ

materially from expectations. Readers are cautioned not to place undue reliance on these forward-looking statements,

which speak only as of their dates, and they should not be relied upon in making purchasing decisions.

Legal disclaimer

Page 3: Olingo Unleashed using Olingo JPA for prototyping and ... · CUSTOMER Riley B Rainey Cloud Architect, Global SAP Cloud Platform Team Olingo Unleashed –using Olingo JPA for prototyping

3CUSTOMER© 2017 SAP SE or an SAP affiliate company. All rights reserved. ǀ

About Olingo

A Sample Olingo JPA project

Olingo JPA Project Structure in source code

Two Quick Approaches to defining your own OData model using JPA

Deploying Java web apps on SAP Cloud Platform

Tricks and Summary

Today’s Agenda

Page 4: Olingo Unleashed using Olingo JPA for prototyping and ... · CUSTOMER Riley B Rainey Cloud Architect, Global SAP Cloud Platform Team Olingo Unleashed –using Olingo JPA for prototyping

4CUSTOMER© 2017 SAP SE or an SAP affiliate company. All rights reserved. ǀ

Essentials

• Familiarity with OData web services

• Java development in Eclipse

• Maven

Helpful

• Familiarity with

• Java Persistence Architecture (JPA) APIs

• Eclipse JPA tooling

• JPA Annotations

Skills you will need

Page 5: Olingo Unleashed using Olingo JPA for prototyping and ... · CUSTOMER Riley B Rainey Cloud Architect, Global SAP Cloud Platform Team Olingo Unleashed –using Olingo JPA for prototyping

5CUSTOMER© 2017 SAP SE or an SAP affiliate company. All rights reserved. ǀ

Implements the OData web services protocol

Server

• OData V2 Java

• OData V4 Java

Client

• Java

• JavaScript V4

• OData used extensively in SAP client

software, including Fiori (SAPUI5), Web

IDE, and Mobile Platform

About Olingo

Page 6: Olingo Unleashed using Olingo JPA for prototyping and ... · CUSTOMER Riley B Rainey Cloud Architect, Global SAP Cloud Platform Team Olingo Unleashed –using Olingo JPA for prototyping

6CUSTOMER© 2017 SAP SE or an SAP affiliate company. All rights reserved. ǀ

Olingo includes several Maven Archetypes

useful for creating sample projects to use as

starting points for new projects.

See Olingo 2 documentation for information

about the JPA archetype.

mvn archetype:generate \

-DinteractiveMode=false \

-Dversion=1.0.0-SNAPSHOT \

-DgroupId=com.sample \

-DartifactId=my-car-service \

-DarchetypeGroupId=org.apache.olingo \

-DarchetypeArtifactId=olingo-odata2-sample-

cars-service-archetype \

-DarchetypeVersion=RELEASE

If you insist on doing this the long way …

Page 7: Olingo Unleashed using Olingo JPA for prototyping and ... · CUSTOMER Riley B Rainey Cloud Architect, Global SAP Cloud Platform Team Olingo Unleashed –using Olingo JPA for prototyping

7CUSTOMER© 2017 SAP SE or an SAP affiliate company. All rights reserved. ǀ

https://github.com/SAP/sap_mobile_platform_espm_olingo_services

Start with a template project

Page 8: Olingo Unleashed using Olingo JPA for prototyping and ... · CUSTOMER Riley B Rainey Cloud Architect, Global SAP Cloud Platform Team Olingo Unleashed –using Olingo JPA for prototyping

8CUSTOMER© 2017 SAP SE or an SAP affiliate company. All rights reserved. ǀ

Elements of the Olingo JPA Project

web.xmlService

Factory class

JPA Object 1

JPA Object n

persistence.xml

.

.

.

Java CodeWEB-INF

Your JPA

persistence unit

Table 1

Table n

.

.

.

Database

Page 9: Olingo Unleashed using Olingo JPA for prototyping and ... · CUSTOMER Riley B Rainey Cloud Architect, Global SAP Cloud Platform Team Olingo Unleashed –using Olingo JPA for prototyping

9CUSTOMER© 2017 SAP SE or an SAP affiliate company. All rights reserved. ǀ

Logically connects a URL pattern to your

OData API

Connects the OData Service to your JPA Entity

Manager factory

Other Initialization (more on this later)

WEB-INF/web.xml – set Olingo Service Factory Class

Page 10: Olingo Unleashed using Olingo JPA for prototyping and ... · CUSTOMER Riley B Rainey Cloud Architect, Global SAP Cloud Platform Team Olingo Unleashed –using Olingo JPA for prototyping

10CUSTOMER© 2017 SAP SE or an SAP affiliate company. All rights reserved. ǀ

Top Down

“I can define Java classes to represent my new

OData service”

• Define your object model as Java Objects

• Add JPA Annotations to define relationships

• JPA in your OData web service project will

generate the schema on-demand

Bottom Up

“I have an existing SQL database and I want to

make an OData service out of it”

• Use Eclipse JPA tooling convert your

existing SQL database schema to JPA

entities in your project.

• Tables, columns, relations inspected

• JPA Annotations generated automatically

Leveraging JPA in an Olingo Project – Two Paths

Page 11: Olingo Unleashed using Olingo JPA for prototyping and ... · CUSTOMER Riley B Rainey Cloud Architect, Global SAP Cloud Platform Team Olingo Unleashed –using Olingo JPA for prototyping

11CUSTOMER© 2017 SAP SE or an SAP affiliate company. All rights reserved. ǀ

Elements of the Olingo JPA Project

web.xmlService

Factory class

JPA Object 1

JPA Object n

persistence.xml

.

.

.

Java CodeWEB-INF

Your JPA

persistence unit

Table 1

Table n

.

.

.

Database

Page 12: Olingo Unleashed using Olingo JPA for prototyping and ... · CUSTOMER Riley B Rainey Cloud Architect, Global SAP Cloud Platform Team Olingo Unleashed –using Olingo JPA for prototyping

12CUSTOMER© 2017 SAP SE or an SAP affiliate company. All rights reserved. ǀ

Trick #3

Preload Initial Data Sets

• Your Service Factory class

can be programmed to

detect “first call” and load an

initial data set

Trick #2

Tune the naming in your data

model

• An XML file can be used to

tweak the OData Object,

Property, and Association

names

• Use

setJPAEdmMappingModel()

Trick #1

Use an embedded SQL

database

• Choice of Derby or

Hypersonic (hsqldb)

• Each user gets a private

copy (modify at will)

• Destroyed when you stop

the server (at least in SAP

Cloud Platform)

Olingo JPA Prototyping Tricks

Page 13: Olingo Unleashed using Olingo JPA for prototyping and ... · CUSTOMER Riley B Rainey Cloud Architect, Global SAP Cloud Platform Team Olingo Unleashed –using Olingo JPA for prototyping

13CUSTOMER© 2017 SAP SE or an SAP affiliate company. All rights reserved. ǀ

Apache Olingo site

https://olingo.apache.org/

Sample project used in this presentation

https://github.com/SAP/sap_mobile_platform_espm_olingo_services

Example of Cloud Platform Users as Objects in an OData model (using Java & neo SDK)

https://github.com/SAP/cloud-olingo-identity-ochat

Another approach to integrating a existing JPA project

https://olingo.apache.org/doc/odata2/tutorials/CreateWebApp.html

Get a SAP Cloud Platform Free Trial Account

https://cloudplatform.sap.com/index.html

References

Page 14: Olingo Unleashed using Olingo JPA for prototyping and ... · CUSTOMER Riley B Rainey Cloud Architect, Global SAP Cloud Platform Team Olingo Unleashed –using Olingo JPA for prototyping

SAP Cloud Platform

Riley B Rainey

[email protected]

Twitter: @rileyrainey

Page 15: Olingo Unleashed using Olingo JPA for prototyping and ... · CUSTOMER Riley B Rainey Cloud Architect, Global SAP Cloud Platform Team Olingo Unleashed –using Olingo JPA for prototyping

SAP‘s Digital Transformation Platform

SAP S/4 HANASAP

BW/4 HANA SAP Cloud Platform

SAP Cloud Applications

CustomerSpecific

and 3rd PartyApplications

BusinessObject Cloud

and Digital Boardroom

SAP API Business Hub

Business Services IoT ServicesML ServicesUX Services Mobile Services

Big Data Cloud

VoraSAP HANA

SAP Fiori

Page 16: Olingo Unleashed using Olingo JPA for prototyping and ... · CUSTOMER Riley B Rainey Cloud Architect, Global SAP Cloud Platform Team Olingo Unleashed –using Olingo JPA for prototyping

© 2017 SAP SE or an SAP affiliate company. All rights reserved.

No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP SE or an SAP affiliate company.

SAP and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP SE (or an SAP affiliate

company) in Germany and other countries. Please see http://global12.sap.com/corporate-en/legal/copyright/index.epx for additional trademark information and notices.

Some software products marketed by SAP SE and its distributors contain proprietary software components of other software vendors.

National product specifications may vary.

These materials are provided by SAP SE or an SAP affiliate company for informational purposes only, without representation or warranty of any kind, and SAP SE or its

affiliated companies shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP SE or SAP affiliate company products and

services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as

constituting an additional warranty.

In particular, SAP SE or its affiliated companies have no obligation to pursue any course of business outlined in this document or any related presentation, or to develop

or release any functionality mentioned therein. This document, or any related presentation, and SAP SE’s or its affiliated companies’ strategy and possible future

developments, products, and/or platform directions and functionality are all subject to change and may be changed by SAP SE or its affiliated companies at any time

for any reason without notice. The information in this document is not a commitment, promise, or legal obligation to deliver any material, code, or functionality. All forward-

looking statements are subject to various risks and uncertainties that could cause actual results to differ materially from expectations. Readers are cautioned not to place

undue reliance on these forward-looking statements, which speak only as of their dates, and they should not be relied upon in making purchasing decisions.