Skip to content

Commit

Permalink
Add explicit inverse relationship names
Browse files Browse the repository at this point in the history
  • Loading branch information
Windvis committed Jul 30, 2021
1 parent cd53c95 commit 1b0e5d6
Show file tree
Hide file tree
Showing 22 changed files with 308 additions and 65 deletions.
23 changes: 19 additions & 4 deletions app/models/administrative-unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,23 @@ import { hasMany, belongsTo } from '@ember-data/model';
import OrganizationModel from './organization';

export default class AdministrativeUnitModel extends OrganizationModel {
@belongsTo('administrative-unit-classification-code') classification;
@belongsTo('location', { inverse: 'administrativeUnit' }) scope;
@hasMany('governing-body', { inverse: 'administrativeUnit' }) governingBodies;
@hasMany('local-involvement') involvedBoards;
@belongsTo('administrative-unit-classification-code', {
inverse: null,
})
classification;

@belongsTo('location', {
inverse: 'administrativeUnit',
})
scope;

@hasMany('governing-body', {
inverse: 'administrativeUnit',
})
governingBodies;

@hasMany('local-involvement', {
inverse: 'administrativeUnit',
})
involvedBoards;
}
18 changes: 15 additions & 3 deletions app/models/agent-in-position.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,19 @@ import Model, { attr, hasMany, belongsTo } from '@ember-data/model';
export default class AgentInPositionModel extends Model {
@attr('date') agentStartDate;
@attr('date') agentEndDate;
@belongsTo('post') position;
@belongsTo('person') person;
@hasMany('contact-point') contacts;

@belongsTo('post', {
inverse: 'agentsInPosition',
})
position;

@belongsTo('person', {
inverse: 'agentsInPosition',
})
person;

@hasMany('contact-point', {
inverse: null,
})
contacts;
}
18 changes: 15 additions & 3 deletions app/models/associated-legal-structure.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,19 @@ import Model, { attr, belongsTo } from '@ember-data/model';

export default class AssociatedLegalStructureModel extends Model {
@attr name;
@belongsTo('identifier') registration;
@belongsTo('legal-form-type') legalType;
@belongsTo('address') address;

@belongsTo('identifier', {
inverse: null,
})
registration;

@belongsTo('legal-form-type', {
inverse: null,
})
legalType;

@belongsTo('address', {
inverse: null,
})
address;
}
6 changes: 5 additions & 1 deletion app/models/change-event.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,9 @@ import Model, { attr, belongsTo } from '@ember-data/model';
export default class ChangeEventModel extends Model {
@attr('date') date;
@attr description;
@belongsTo('change-event-type') type;

@belongsTo('change-event-type', {
inverse: null,
})
type;
}
6 changes: 5 additions & 1 deletion app/models/contact-point.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,9 @@ export default class ContactPointModel extends Model {
@attr telephone;
@attr fax;
@attr website;
@belongsTo('address') contactAddress;

@belongsTo('address', {
inverse: null,
})
contactAddress;
}
27 changes: 22 additions & 5 deletions app/models/governing-body.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,31 @@ import Model, { attr, hasMany, belongsTo } from '@ember-data/model';
export default class GoverningBodyModel extends Model {
@attr('date') startDate;
@attr('date') endDate;
@belongsTo('administrative-unit') administrativeUnit;
@belongsTo('governing-body-classification-code', { inverse: null })

@belongsTo('administrative-unit', {
inverse: 'governingBodies',
})
administrativeUnit;

@belongsTo('governing-body-classification-code', {
inverse: null,
})
classification;
@belongsTo('governing-body', { inverse: 'hasTimeSpecializations' })

@belongsTo('governing-body', {
inverse: 'hasTimeSpecializations',
})
isTimeSpecializationOf;
@hasMany('governing-body', { inverse: 'isTimeSpecializationOf' })

@hasMany('governing-body', {
inverse: 'isTimeSpecializationOf',
})
hasTimeSpecializations;
@hasMany('mandate') mandates;

@hasMany('mandate', {
inverse: 'governingBody',
})
mandates;

get period() {
let period = '';
Expand Down
6 changes: 5 additions & 1 deletion app/models/identifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@ import Model, { attr, belongsTo } from '@ember-data/model';

export default class IdentifierModel extends Model {
@attr idName;
@belongsTo('structured-identifier') structuredIdentifier;

@belongsTo('structured-identifier', {
inverse: null,
})
structuredIdentifier;
}
17 changes: 14 additions & 3 deletions app/models/local-involvement.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,19 @@ import Model, { attr, belongsTo } from '@ember-data/model';

export default class PublicInvolvementModel extends Model {
@attr percentage;
@belongsTo('involvement-type') involvementType;
@belongsTo('worship-service') worshipService;
@belongsTo('administrative-unit', { inverse: 'involvedBoards' })

@belongsTo('involvement-type', {
inverse: null,
})
involvementType;

@belongsTo('worship-service', {
inverse: 'involvements',
})
worshipService;

@belongsTo('administrative-unit', {
inverse: 'involvedBoards',
})
administrativeUnit;
}
6 changes: 5 additions & 1 deletion app/models/location.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,9 @@ import Model, { attr, hasMany } from '@ember-data/model';
export default class LocationModel extends Model {
@attr label;
@attr level;
@hasMany('administrative-unit', { inverse: 'scope' }) administrativeUnit;

@hasMany('administrative-unit', {
inverse: 'scope',
})
administrativeUnit;
}
17 changes: 14 additions & 3 deletions app/models/mandate.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,18 @@ import { hasMany, belongsTo } from '@ember-data/model';
import PostModel from './post';

export default class MandateModel extends PostModel {
@belongsTo('board-position') roleBoard;
@belongsTo('governing-body', { inverse: 'mandates' }) governingBody;
@hasMany('mandatory', { inverse: 'mandate' }) heldBy;
@belongsTo('board-position', {
inverse: null,
})
roleBoard;

@belongsTo('governing-body', {
inverse: 'mandates',
})
governingBody;

@hasMany('mandatory', {
inverse: 'mandate',
})
heldBy;
}
24 changes: 20 additions & 4 deletions app/models/mandatory.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,24 @@ import AgentInPositionModel from './agent-in-position';
export default class MandatoryModel extends AgentInPositionModel {
@attr('date') startDate;
@attr('date') endDate;
@belongsTo('mandatory-status-code') status;
@belongsTo('person') governingAlias;
@belongsTo('mandate') mandate;
@hasMany('contact-point') contacts;

@belongsTo('mandatory-status-code', {
inverse: null,
})
status;

@belongsTo('person', {
inverse: 'mandatories',
})
governingAlias;

@belongsTo('mandate', {
inverse: 'heldBy',
})
mandate;

@hasMany('contact-point', {
inverse: null,
})
contacts;
}
12 changes: 10 additions & 2 deletions app/models/minister-condition.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ import Model, { attr, belongsTo } from '@ember-data/model';

export default class MinisterConditionModel extends Model {
@attr satisfied;
@belongsTo('minister-conditions-criterion') criterion;
@belongsTo('document-type-criterion') documentTypeCriterion;

@belongsTo('minister-conditions-criterion', {
inverse: null,
})
criterion;

@belongsTo('document-type-criterion', {
inverse: null,
})
documentTypeCriterion;
}
16 changes: 13 additions & 3 deletions app/models/minister-position.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,18 @@ import { belongsTo } from '@ember-data/model';
import PostModel from './post';

export default class MinisterPositionModel extends PostModel {
@belongsTo('minister-position-function') function;
@belongsTo('worship-service', { inverse: 'ministerPositions' })
@belongsTo('minister-position-function', {
inverse: null,
})
function;

@belongsTo('worship-service', {
inverse: 'ministerPositions',
})
worshipService;
@belongsTo('representative-body') representativeBody;

@belongsTo('representative-body', {
inverse: 'ministerPositions',
})
representativeBody;
}
17 changes: 14 additions & 3 deletions app/models/minister.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,18 @@ import { hasMany, belongsTo } from '@ember-data/model';
import AgentInPositionModel from './agent-in-position';

export default class MinisterModel extends AgentInPositionModel {
@belongsTo('minister-position') ministerPosition;
@belongsTo('financing-code') financing;
@hasMany('minister-condition') conditions;
@belongsTo('minister-position', {
inverse: null,
})
ministerPosition;

@belongsTo('financing-code', {
inverse: null,
})
financing;

@hasMany('minister-condition', {
inverse: null,
})
conditions;
}
63 changes: 52 additions & 11 deletions app/models/organization.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,59 @@ import Model, { attr, hasMany, belongsTo } from '@ember-data/model';
export default class OrganizationModel extends Model {
@attr name;
@attr alternativeName;
@belongsTo('site') primarySite;
@belongsTo('organization-status-code') organizationStatus;
@hasMany('identifier', { inverse: null }) identifiers;
@hasMany('site', { inverse: null }) sites;
@hasMany('change-event', { inverse: null }) changedBy;
@hasMany('change-event', { inverse: null }) resultedFrom;
@hasMany('post', { inverse: null }) positions;
@hasMany('organization', { inverse: 'isSubOrganizationOf' }) subOrganizations;
@belongsTo('organization', { inverse: 'subOrganizations' })

@belongsTo('site', {
inverse: null,
})
primarySite;

@belongsTo('organization-status-code', {
inverse: null,
})
organizationStatus;

@hasMany('identifier', {
inverse: null,
})
identifiers;

@hasMany('site', {
inverse: null,
})
sites;

@hasMany('change-event', {
inverse: null,
})
changedBy;

@hasMany('change-event', {
inverse: null,
})
resultedFrom;

@hasMany('post', {
inverse: null,
})
positions;

@hasMany('organization', {
inverse: 'isSubOrganizationOf',
})
subOrganizations;

@belongsTo('organization', {
inverse: 'subOrganizations',
})
isSubOrganizationOf;
@hasMany('organization', { inverse: 'isAssociatedWith' })

@hasMany('organization', {
inverse: 'isAssociatedWith',
})
associatedOrganizations;
@belongsTo('organization', { inverse: 'associatedOrganizations' })

@belongsTo('organization', {
inverse: 'associatedOrganizations',
})
isAssociatedWith;
}
30 changes: 25 additions & 5 deletions app/models/person.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,29 @@ export default class PersonModel extends Model {
@attr givenName;
@attr familyName;
@attr firstNameUsed;
@hasMany('mandatory', { inverse: 'governingAlias' }) mandatories;
@hasMany('agent-in-position', { inverse: 'person' }) agentsInPosition;
@hasMany('nationality') nationalities;
@belongsTo('date-of-birth') dateOfBirth;
@belongsTo('gender-code') gender;

@hasMany('mandatory', {
inverse: 'governingAlias',
})
mandatories;

@hasMany('agent-in-position', {
inverse: 'person',
})
agentsInPosition;

@hasMany('nationality', {
inverse: null,
})
nationalities;

@belongsTo('date-of-birth', {
inverse: null,
})
dateOfBirth;

@belongsTo('gender-code', {
inverse: null,
})
gender;
}
Loading

0 comments on commit 1b0e5d6

Please sign in to comment.