createDomainModel function

Model createDomainModel()

Implementation

Model createDomainModel() {
  Domain domain = new Domain('DirectDemocracy');
  Model model = new Model(domain, 'DirectDemocracyModel');
  assert(domain.models.length == 1);

  Concept userConcept = new Concept(model, 'User');
  userConcept.description = 'Represents a registered user on the platform.';
  assert(model.concepts.length == 1);
  new Attribute(userConcept, 'email').identifier = true;
  new Attribute(userConcept, 'name');
  new Attribute(userConcept, 'password');
  // ...

  Concept proposalConcept = new Concept(model, 'Proposal');
  proposalConcept.description =
      'Represents a proposal for a decision or action to be taken within a particular context.';
  assert(model.concepts.length == 2);
  new Attribute(proposalConcept, 'id').identifier = true;
  new Attribute(proposalConcept, 'title');
  new Attribute(proposalConcept, 'description');
  // ...

  Concept voteConcept = new Concept(model, 'Vote');
  voteConcept.description =
      'Represents a vote cast by a user on a particular proposal.';
  assert(model.concepts.length == 3);
  new Attribute(voteConcept, 'id').identifier = true;
  new Attribute(voteConcept, 'voteType');
  // ...

  Concept issueConcept = new Concept(model, 'Issue');
  issueConcept.description =
      'Represents a topic or question that is open for discussion and debate among users on the platform.';
  assert(model.concepts.length == 4);
  new Attribute(issueConcept, 'id').identifier = true;
  new Attribute(issueConcept, 'title');
  new Attribute(issueConcept, 'description');
  // ...

  Concept commentConcept = new Concept(model, 'Comment');
  commentConcept.description =
      'Represents a comment made by a user on a particular issue.';
  assert(model.concepts.length == 5);
  new Attribute(commentConcept, 'id').identifier = true;
  new Attribute(commentConcept, 'text');
  // ...

  Concept expertConcept = new Concept(model, 'Expert');
  expertConcept.description =
      'Represents a user who has specialized knowledge or experience in a particular field or topic.';
  assert(model.concepts.length == 6);
  new Attribute(expertConcept, 'fieldOfExpertise').identifier = true;
// ...

  Child userProposalsNeighbor =
      new Child(userConcept, proposalConcept, 'proposals');
  Parent proposalUserNeighbor =
      new Parent(proposalConcept, userConcept, 'user');
  proposalUserNeighbor.identifier = true;
  userProposalsNeighbor.opposite = proposalUserNeighbor;
  proposalUserNeighbor.opposite = userProposalsNeighbor;
  assert(userConcept.children.length == 1);
  assert(proposalConcept.parents.length == 1);
  assert(userConcept.sourceParents.length == 1);
  assert(proposalConcept.sourceChildren.length == 1);

  Child proposalVotesNeighbor =
      new Child(proposalConcept, voteConcept, 'votes');
  Parent voteProposalNeighbor =
      new Parent(voteConcept, proposalConcept, 'proposal');
  voteProposalNeighbor.identifier = true;
  proposalVotesNeighbor.opposite = voteProposalNeighbor;
  voteProposalNeighbor.opposite = proposalVotesNeighbor;
  assert(proposalConcept.children.length == 1);
  assert(voteConcept.parents.length == 1);
  assert(proposalConcept.sourceParents.length == 1);
  assert(voteConcept.sourceChildren.length == 1);

  Child issueCommentsNeighbor =
      new Child(issueConcept, commentConcept, 'comments');
  Parent commentIssueNeighbor =
      new Parent(commentConcept, issueConcept, 'issue');
  commentIssueNeighbor.identifier = true;
  issueCommentsNeighbor.opposite = commentIssueNeighbor;
  commentIssueNeighbor.opposite = issueCommentsNeighbor;
  assert(issueConcept.children.length == 1);
  assert(commentConcept.parents.length == 1);
  assert(issueConcept.sourceParents.length == 1);
  assert(commentConcept.sourceChildren.length == 1);

  Child userCommentsNeighbor =
      new Child(userConcept, commentConcept, 'comments');
  Parent commentUserNeighbor = new Parent(commentConcept, userConcept, 'user');
  commentUserNeighbor.identifier = true;
  userCommentsNeighbor.opposite = commentUserNeighbor;
  commentUserNeighbor.opposite = userCommentsNeighbor;
  assert(userConcept.children.length == 1);
  assert(commentConcept.parents.length == 1);
  assert(userConcept.sourceParents.length == 1);
  assert(commentConcept.sourceChildren.length == 1);

  Child expertUsersNeighbor = new Child(expertConcept, userConcept, 'users');
  Parent userExpertNeighbor = new Parent(userConcept, expertConcept, 'expert');
  userExpertNeighbor.identifier = true;
  expertUsersNeighbor.opposite = userExpertNeighbor;
  userExpertNeighbor.opposite = expertUsersNeighbor;
  assert(expertConcept.children.length == 1);
  assert(userConcept.parents.length == 1);
  assert(expertConcept.sourceParents.length == 1);
  assert(userConcept.sourceChildren.length == 1);

  return model;
}