Skip to content

Commit

Permalink
Core: refactor storage layer, pt.7 (#391).
Browse files Browse the repository at this point in the history
Does not yet compile.

See ticket 391.
  • Loading branch information
jri committed Jan 3, 2013
1 parent a276f35 commit 8049849
Show file tree
Hide file tree
Showing 7 changed files with 240 additions and 163 deletions.
Expand Up @@ -219,9 +219,9 @@ public Set<Topic> getTopics(String roleTypeUri) {

@Override
public RelatedAssociation getRelatedAssociation(String assocTypeUri, String myRoleTypeUri,
String othersRoleTypeUri) {
String othersRoleTypeUri) {
RelatedAssociationModel assoc = dms.storage.getAssociationRelatedAssociation(getId(),
assocTypeUri, myRoleTypeUri, othersRoleTypeUri);
assocTypeUri, myRoleTypeUri, othersRoleTypeUri, null); // othersAssocTypeUri=null
return assoc != null ? dms.attach(assoc, false, false) : null; // fetchComposite=false,
// fetchRelatingComposite=false
}
Expand Down
Expand Up @@ -21,6 +21,15 @@ class AttachedAssociationRole extends AttachedRole implements AssociationRole {



// === Implementation of the abstract methods ===

@Override
void storeRoleTypeUri() {
dms.storage.storeRoleTypeUri(getAssociation().getId(), getPlayerId(), getRoleTypeUri());
}



// === AttachedRole Overrides ===

@Override
Expand Down
Expand Up @@ -8,7 +8,7 @@



class AttachedRole implements Role {
abstract class AttachedRole implements Role {

// ---------------------------------------------------------------------------------------------- Instance Variables

Expand Down Expand Up @@ -45,7 +45,10 @@ public String getRoleTypeUri() {

@Override
public void setRoleTypeUri(String roleTypeUri) {
// update memory
model.setRoleTypeUri(roleTypeUri);
// update DB
storeRoleTypeUri(); // abstract
}

// ---
Expand All @@ -68,4 +71,8 @@ public RoleModel getModel() {
public JSONObject toJSON() {
return getModel().toJSON();
}

// ----------------------------------------------------------------------------------------- Package Private Methods

abstract void storeRoleTypeUri();
}
Expand Up @@ -54,14 +54,11 @@ public Topic getTopic() {



// === Role Overrides ===
// === Implementation of the abstract methods ===

@Override
public void setRoleTypeUri(String roleTypeUri) {
// 1) update memory
super.setRoleTypeUri(roleTypeUri);
// 2) update DB
storeRoleTypeUri(roleTypeUri);
void storeRoleTypeUri() {
dms.storage.storeRoleTypeUri(getAssociation().getId(), getPlayerId(), getRoleTypeUri());
}


Expand All @@ -72,14 +69,4 @@ public void setRoleTypeUri(String roleTypeUri) {
public TopicRoleModel getModel() {
return (TopicRoleModel) super.getModel();
}

// ------------------------------------------------------------------------------------------------- Private Methods



// === Store ===

private void storeRoleTypeUri(String roleTypeUri) {
dms.storage.setRoleTypeUri(getAssociation().getId(), getPlayerId(), roleTypeUri);
}
}

0 comments on commit 8049849

Please sign in to comment.