19
Persistence SQL, Domain & Fenix Framework

Training: Day Three - Persistence

Embed Size (px)

DESCRIPTION

This is the third in our four part training sessions introducing FenixEdu development for new collaborators. In this third session, we introduce our persistence technology and database engine as well how to commit database changes to version control.

Citation preview

Page 1: Training: Day Three - Persistence

PersistenceSQL, Domain & Fenix Framework

Page 2: Training: Day Three - Persistence

How to change your gradesSQL, Domain & Fenix Framework

Page 3: Training: Day Three - Persistence

MySQL

Application Container (Tomcat, Jetty)

Fenix Framework(STM)

DomainModel

JSPrenderers

Struts

Faces

Jersey(REST API)

Page 4: Training: Day Three - Persistence

Fenix Framework

● Software Transactional Machine

● Developed in part by our Team

● Available at:○ https://github.com/fenix-framework/fenix-framework

Page 5: Training: Day Three - Persistence

Fenix Framework

class PendingRequest {

DateTime generationDate;

String url;

Boolean post;

String buildVersion;

}

relation PendingRequestRootDomainObject {

RootDomainObject playsRole rootDomainObject;

PendingRequest playsRole pendingRequest {

multiplicity *;

}

}

DML

Page 6: Training: Day Three - Persistence

Fenix FrameworkDML

valueType java.math.BigDecimal as BigDecimal {

externalizeWith {

String toString();

}

}

enum net.sourceforge.fenixedu.util.WeekDay as WeekDay;

Page 7: Training: Day Three - Persistence

Fenix Framework

Entity DomainObjectRootDomainObject

1 *

DML

Page 8: Training: Day Three - Persistence

Fenix Framework

class Degree extends AcademicProgram {

Double ectsCredits;

String nome (REQUIRED);

}

DML

Page 9: Training: Day Three - Persistence

Fenix Framework

@ConsistencyPredicate

private boolean checkRequiredSlots() {

ConsistencyChecks.checkRequired(this, "nome", getNome());

return true;

}

DML

Page 10: Training: Day Three - Persistence

Fenix FrameworkTransactions

● Use @Atomic

● Can be READ, WRITE, SPECULATIVE_READ

● DO NOT USE IN ACTIONS!

Page 11: Training: Day Three - Persistence

Fenix Framework

● /src/main/dml/domain_model.dml

● 1370 Entities, 1802 Relations, 54 Value Types & 200 Enums

DML

Page 12: Training: Day Three - Persistence
Page 13: Training: Day Three - Persistence

Fenix FrameworkFenix Domain Browser

● Available at:○ https://fenix-ashes.ist.utl.pt/fdb/

● Source code at:○ https://github.com/nurv/Fenix-Domain-Browser

● Demo:

Page 14: Training: Day Three - Persistence

Fenix FrameworkChanges

● Edit domain_model.dml.● Run mvn clean test -PSQLUpdateGenerator● Edit /etc/database_operations/updates.sql● Rename updates.sql● Edit /etc/database_operations/run● Run /etc/database_operations/run

Page 15: Training: Day Three - Persistence

⚠BE CAREFUL!

Page 16: Training: Day Three - Persistence

Fenix FrameworkDumps

● Goto:○ https://fenix-ashes.ist.utl.pt/jenkins/

● Demo

Page 17: Training: Day Three - Persistence

MySQL

● You are going to run the database in a remote server.

● How to connect:○ ssh -A -fNg -L <localport>:localhost:3306

[email protected]

○ mysql -h localhost -u<istid> --protocol=TCP -P <localport> -p<dbpass> <istid>_fenix -A

Page 18: Training: Day Three - Persistence

MySQL

● Edit fenix-framework.properties:○ dbAlias=//localhost:<localport>/<istid>_fenix?

useUnicode=true&characterEncoding=utf8&clobCha

racterEncoding=utf8&zeroDateTimeBehavior=convertToNull

○ dbUsername=<istid>○ dbPassword=<dbpass>

Page 19: Training: Day Three - Persistence

So, how do you change your marks?