• Nenhum resultado encontrado

Collections create collection Contacts : set of contact

N/A
N/A
Protected

Academic year: 2022

Share "Collections create collection Contacts : set of contact"

Copied!
49
0
0

Texto

(1)

Avon Implementation

(2)

Overview

ƒ

Avon Interfaces

ƒ

Avon Model

ƒ

Avon Storage

ƒ

Avon Query Processor

ƒ

Demo

(3)

Avon Interfaces

ƒ

Programmatic Interface: OMSjp 1.2

ƒ

OML (last week)

ƒ

Graphical Interfaces

ƒ Eclipse Plugin

ƒ OMSjp Browser (DEMO)

(4)

Programmatic Interface

Programmatic Interface: OMSjp

ƒ

Java interface to OM model

ƒ

Support for multiple inheritance, classification, role modeling, query, data definition and

manipulation

(5)

Architecture

ƒ Client-Server

ƒ Multiple clients

Java Virtual Machine

Database Application

OMSjp

OMS Platform OMSjp Interface

Driver(s) Cache Java Virtual Machine

Database Application

OMSjp

OMS Platform OMSjp Interface

Driver(s) Cache

ƒ Inprocess

ƒ Personal mobile information systems

(6)

OMS Driver

ƒ

Abstraction from underlying OM Implementation

ƒ One per platform

ƒ

DriverManager

ƒ

Driver configuration via URL

ƒ

Similar to JDBC

<omsjp:platform:user/password@host:port/database>

<omsjp:avon:stefania/***@localhost/test.oms>

(7)

Mapping OM to Java

ƒ A person can be both, student and employee

ƒ Multiple Instantiation

ƒ Impedance mismatch with Java

person

student phd student employee

(8)

Mapping OM to Java…

Metamodel of OM Object

(9)

Most Important Classes

ƒ

OMSObject

ƒ

OMSObjectType

ƒ

OMSInstance

ƒ

OMSCollection

ƒ

OMSAssociation

(10)

Example: Type Schema

create type contact (…);

create type person subtype of contact ();

create type location (…);

create type organisation subtype of contact (…);

contact

person organisation

location

(11)

Example: Classification Schema

contact

Contacts

person

Persons

organisation

Organisations

cover

location

Locations located_at

(0:*) (0:*)

lives_at (1:*)

(0:*)

// Collections

create collection Contacts : set of contact;

create collection Persons : set of person;

create collection Organisations : set of organisation;

(12)

OMSObject

ƒ dress(ObjectType type), strip(ObjectType type)

ƒ setAttributeValue(…), getAttributeValue(…)

//create john object and set attribute values

final OMSObjectType contactType = database.getObjectType(“contact");

final OMSObject john = database.createObject(contactType);

john.setAttributeValue(contactType, “name", "John");

//dress john as person john.dress(personType);

john.setAttributeValue(personType, “birthDate", "20.12.1978");

(13)

OMSObject…

ƒ getMembershipCollections(), getMembershipCollections(Type type)

ƒ getLink(OMSAssociation assoc) and inverse

//get johns locations

final List<OMSObject> locations = john.getLinks(locatedAtAssoc) //get johns homeplaces

final List<OMSObject> homeplaces = john.getLinks(livesAtAssoc) //get membership collections

final List<OMSCollection> colls = john.getMembershipCollections()

homeplaces locations

(14)

OMSObject and OMSInstance

final Person johnPerson = (Person)john.browse(personType);

String birthDate = johnPerson.getBirthDate();

final Contact johnContact = (Contact)john.browse(contactType) johnContact.setName(“Johnny”);

ƒ getInstances(), getDressTypes()

ƒ browse(ObjectType type)

(15)

OMSInstance: Contact Class

public class Contact extends AbstractInstance {

public void setName(final String name) throws OMSException { this.setAttributeValue(“name", name);

}

public String getName() throws OMSException {

OMSString s = (OMSString) this.getAttributeValue(“name");

return s.getString();

} ...

}

Instance registration: Mapping of Java classes to database types contact=ch.ethz.globis.test.Contact

(16)

How to implement the OMSjp classes?

ƒ

Create data

objects, types, collections, hierarchies, constraints

ƒ

Access data

getAttributeValue(…): …

ƒ

Manipulate data

setAttributeValue(…)

ƒ

Processing

executeMethod(…): …

ƒ

Collections

add, retrieve, remove members, hierarchies, constraints

ƒ

ƒ

… and Persistent

(17)

Model and Metamodel

ƒ

OMSjp interfaces represent metamodel concepts

ƒ

Interface implementation implements a metamodel

object Objects

type Types

collection Collections

association Associations disjoint

(18)

Example: A Simple Metamodel

We need to store and retrieve data

ƒ attributes declared by types

ƒ attribute values of objects

ƒ collection membership

ƒ

(19)

Example: A Simple Metamodel …

ƒ Where is it stored that personType has a name and attributes?

personType is an instance of type with name = “personType” and declaring the attributes “name” of type string and “birthdate” of type date

ƒ Where is it stored that type has a name and attributes?

type is an instance of type with name = “type” and declaring the

attributes “name” of type string and “attributes” of type list<attribute>

(20)

Example: A Simple Metamodel …

ƒ What is an attribute?

attribute is an instance of type with name = “attribute” and declaring the attributes “name” of type string and “type” of type type

ƒ (OMSjp Metamodel: What is a collection?

collection is an instance of type with name = “collection” and declaring the attributes “name” of type string and “extent” of type bulktype

ƒ … method, association, hierarchy, constraint?)

(21)

Example: A Simple Metamodel …

ƒ

What Java classes can we use to represent

person objects, person types, types, attributes?

ƒ

What is common to all these objects?

They are all objects which store values for the attributes declared by their types

final Object personType = new Object();

personType.dress(TYPE);

personType.setAttributeValue(TYPE, nameAttribute, “person");

personType.setAttributeValue(TYPE, attributesAttribute, …);

final Object person = new Object();

person.dress(personType);

person.setAttributeValue(personType, nameAttribute, “daniel");

(22)

A Vicious Circle

final Object type = new Object();

type.dress(type);

type.setAttributeValue(type, nameAttribute, “type");

final Object nameAttribute = new Object();

nameAttribute.dress(attribute);

final Object attribute = new Object();

attribute.dress(type);

• Type has not declared its attributes

• Name attribute does not exist

• Attribute type does not exist

• Type has not declared its attributes

• Name attribute has not been initialised

ƒ When creating the type type we want to set its attributes “name” and

“attributes”.

ƒ We need the objects representing the “name” and “attributes” attributes

ƒ When creating the “name” attribute we must have the object representing the attribute type

ƒ When creating the attribute type we must have the object representing the type type (… but this is the one we were about to create)

(23)

// create types

final Object object = new Object();

final Object type = new Object();

// create attributes

final Object typeName = new Object();

final Object typeAttributes = new Object();

// dress

object.dress(object);

object.dress(type);

type.dress(object);

// create attribute values

// set type attributes values

object.setAttributeValue(type, typeName, objectNameValue);

object.setAttributeValue(type, typeAttributes, objectAttributesValue);

type.setAttributeValue(type, typeName, typeNameValue);

// set attributes attribute values

typeName.setAttributeValue(attribute, attributeName, typeNameName);

typeName.setAttributeValue(attribute, attributeType, typeNameType);

typeAttributes.setAttributeValue(attribute, attributeName, typeAttributesName);

Bootstrap

ƒ

Kind of pipelining to break out of vicious circle

ƒ

Objects created during bootstrap must be available to user

(24)

Avon Metamodel: Object Types

(25)

Avon Metamodel: Object Types …

name: String Collection

extent: Ranking<? ext Value>

RankingCollection

extent: Set<? ext Value>

SetCollection

extent: Bag<? ext Value>

BagCollection

extent: Sequence<? ext Value>

SequenceCollection

(26)

Avon Metamodel: Collections

(27)

Avon Metamodel: Types and Collections

(0:1)

(0:*)

type

Types

collection

Collections

method

Methods

objectType

ObjectTypes

type

BaseTypes

bulkType

BulkTypes

structuredType

StructuredTypes

partition

ObjectTypeISAs (0:*) (0:*)

BaseTypeISAs (0:*) (0:*) CollectionISAs

(0:*) (0:*)

HasMethods (1:1)

Extent (0:*)

(28)

Java Classes of Avon

initialise() Database CoreBootstrap BaseTypesBootstrap CollectionsBootstrap BootstrapManager

(29)

Java Classes of Avon …

Simplification the creation, retrieval and deletion of OMObject objects that represent the various

metamodel concepts

e.g. CollectionGateway.create(): OMObject

returns OMObject with types object and collection

(30)

Java Classes of Avon …

Simplification of setting and retrieving attribute values of OMObject objects

e.g. AttributeUtils.getName(OMObject): String

if argument is of type attribute, return its name AttributeUtils AssociationUtils

CollectionUtils

TypeUtils

ValueUtils Database

Utils

isAttribute(OMStructuredValue): boolean getName(OMObject): String

setName(OMObject, String) getType(OMObject): OMObject

AttributeUtils

isAssociation(OMObject): boolean getName(OMObject): String setName(OMObject, String)

getDomainCardinality(OMObject): OMStructuredValue getRangeCardinality(OMObject): OMStructuredValue getDomainCollection(OMObject): OMObject getRangeCollection(OMObject): OMObject getRelationCollection(OMObject): OMObject

AssociationUtils

(31)

Java Classes of Avon: Layering

Persistency Object Model

OMSjp

OMObject Database

Utils

Gateway

DBObject InformationUnit AttributeValue StorageBase

Utils

AvonObject AvonInstance AvonValue

AvonAssociation AvonCollection

AvonType

AvonSchema AvonDatabase

OML

Query

db4o

(32)

Storage Layer

ƒ

Uses db4o

ƒ

A new impedance mismatch between OM and java

ƒ

Object activation

(33)

Storage Layer

(34)

Storage Layer - DBObject

ƒ

Corresponds to OMObject from the OM layer

ƒ

Contains references to information units (an information unit for each type)‏

ƒ

Dress adds information units

ƒ

Strip removes information units

(35)

Storage Layer - DBObject

Type : Object

Object

Type : Object

Object

Type : Student Type : Person

Type : Object

Object

Type : Student Type : Person Type : Object

Object

Type : PhDStudent Type : Person

dress (Object, Student)‏

createObject

strip (Object, Student)‏

dress (Object, PhDStudent)‏

(36)

Storage Layer - CompositeValue

ƒ

Base class for StructuredValue and InformationUnit

ƒ

Type (object type or structured type)‏

ƒ

Values – associated with attributes of the type

(37)

Storage Layer - Activation

ƒ

Db4o activation - process of populating the

attributes of an object with previously stored data

container.activate (obj, 1)

ƒ

Transparent activation

(38)

Query Engine

ƒ

Language process with in a three level architecture.

ƒ

Extensions

(39)

Query Engine

(40)

Parser process

ƒ

JavaCC package used to generate parser and lexer.

ƒ

Returns an AST (abstract syntax tree)‏

(41)

QueryTree converter

ƒ

Transforms the AST into a QT (query tree)‏

ƒ

Uses the Visitor design pattern

ƒ

Postorder AST processing

(42)

Query Tree

ƒ

QT nodes are atomic construct that are used to build different database operations (Selection, Domain, Iterator, Object)‏

ƒ

A Visitor interface is associated with the tree structure

(43)

Query Tree

SituatedAt rr (all $l in Locations having

($l.city = "Zurich"))

(44)

Query Tree Evaluator

ƒ

Uses the Visitor interface of the QT

ƒ

Postorder traversal

ƒ

Returns only the last result from the OML script

ƒ

Memorizes the result in the node structure

(45)

Symbol Table

ƒ

Stores temporary object references

ƒ

Organized as a stack.

ƒ

Duplicate names in different scopes are allowed

(46)

Queries - storage layer

ƒ

OM queries are transform into SODA queries

ƒ sel (Locations, city, “Zurich”)‏

ƒ query.constrain (StringValue.class)

query. descend(“value”).constrain (“Zurich”) resStrVal = query.execute();

ƒ

Temporary query results are stored in db4o

(47)

Extensions

ƒ

Allow OML to grow

ƒ

Syntax expanders nodes (AST)‏

ƒ set[ `obj1.version(1.2)`, `obj2.version(1.0)`];

ƒ `grant R to UserName`;

(48)

Extensions

ƒ

An Extension Node is currently generated in the core AST.

ƒ

A separate module processes extension

strings ( `obj1.version(1.2)`, `obj2.version(1.0)`, ...)

ƒ

The extension module will return an AST

(49)

DEMO

Referências

Documentos relacionados

Ecologia da comunidade de metazoários parasitos do peixe-espada Trichiurus lepturus Linnaeus (Osteichthyes, Trichiuridae) do litoral do estado do Rio de Janeiro,

Figura 1: Esquema conceitual de uma bacia de drenagem...18 Figura 2: Representação esquemática do Ciclo Hidrológico...20 Figura 3: Mapa da área de estudo com a localização das

A responsabilidade pelo pagamento dos honorários periciais é da parte sucumbente na pretensão objeto da perícia, salvo se beneficiária de justiça gratuita. Embora seja facultado

This paper analyzes the powerful role of px, yq as linker of spatial knowledge, and describes a practice, Geo Linked Data, that transforms the juxtaposition into a formal link

O Curso por inteiro compreende a duração de um pouco mais de um ano de aulas teóricas sobre judaísmo, vivência comunitária presença no Shabat, nas demais rezas e festas, até

Assim, para causar vasorrelaxamento em aorta torácica de ratos normotensos, R(+)- pulegona, estimula a produção de NO na célula endotelial, provavelmente por ativar o influxo de

Dessa forma, afirma-se que, devido a inúmeros fatores como tráfego, mobilidade dos clientes na rede, a interferência obtida por dispositivos de redes de outros padrões e a

Comparação de resultados do deslocamento máximo obtido com metamodelação e com o SolidWorks para a M2_3DLS caso de flexão lateral esquerda do