Skip to content

Commit

Permalink
Merge branch '7.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
petmongrels committed Feb 13, 2024
2 parents f68627c + 79c793d commit 815110b
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 19 deletions.
20 changes: 7 additions & 13 deletions src/Concept.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,6 @@ export default class Concept extends BaseEntity {
concept.hiNormal = conceptResource.highNormal;
concept.unit = conceptResource.unit;
concept.voided = conceptResource.voided || false; //This change should be independently deployable irrespective of server
//remove orphan keyValues (because KeyValue doesn't have primary key
entityService &&
entityService.deleteObjects(conceptResource["uuid"], Concept.schema.name, "keyValues");
concept.keyValues = _.map(conceptResource.keyValues, KeyValue.fromResource);
return concept;
}
Expand Down Expand Up @@ -200,20 +197,17 @@ export default class Concept extends BaseEntity {
concept.name = name;
concept.datatype = dataType;
concept.uuid = uuid;
concept.keyValues = keyValues;
concept.keyValues = _.map(keyValues, KeyValue.fromResource);
return concept;
}

/**
* This should never be cloned and used for reference as this is metadata which is not to be modified during transactional data operations
*
* @returns {Concept}
*/
cloneForReference() {
const concept = Concept.create(this.name, this.datatype, this.keyValues);
concept.uuid = this.uuid;
concept.unit = this.unit;
concept.lowAbsolute = this.lowAbsolute;
concept.lowNormal = this.lowNormal;
concept.hiNormal = this.hiNormal;
concept.hiAbsolute = this.hiAbsolute;
concept.answers = this.answers || [];
return concept;
return this;
}

_valuePresent(value) {
Expand Down
6 changes: 5 additions & 1 deletion src/EntityMetaData.js
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,11 @@ class EntityMetaData {
}

static entitiesLoadedFromServer() {
return _.differenceBy(EntityMappingConfig.getInstance().getEntities(), [Settings, LocaleMapping], "schema.name");
return _.differenceBy(EntityMappingConfig.getInstance().getEntities(), [Settings, LocaleMapping].concat(EntityMetaData.embeddedEntities()), "schema.name");
}

static embeddedEntities() {
return _.filter(EntityMappingConfig.getInstance().getEntities(), entity => entity.schema.embedded);
}

static findByName(entityName) {
Expand Down
2 changes: 1 addition & 1 deletion src/Observation.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class Observation extends PersistedObject {
}

cloneForEdit() {
return clone(this.concept.cloneForReference(), this.getValueWrapper().cloneForEdit());
return clone(this.concept, this.getValueWrapper().cloneForEdit());
}

shallowClone() {
Expand Down
4 changes: 1 addition & 3 deletions src/application/FormElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,6 @@ class FormElement extends BaseEntity {
);
formElement.concept = concept;

//remove orphan keyValues (because KeyValue doesn't have primary key
entityService.deleteObjects(resource["uuid"], FormElement.schema.name, "keyValues");
formElement.keyValues = _.map(resource.keyValues, KeyValue.fromResource);
formElement.validFormat = Format.fromResource(resource["validFormat"]);
return formElement;
Expand Down Expand Up @@ -432,7 +430,7 @@ class FormElement extends BaseEntity {
formElement.name = this.name;
formElement.displayOrder = this.displayOrder;
formElement.mandatory = this.mandatory;
formElement.keyValues = this.keyValues;
formElement.keyValues = _.map(this.keyValues, KeyValue.fromResource);
formElement.concept = this.concept;
formElement.type = this.type;
formElement.formElementGroup = this.formElementGroup;
Expand Down
2 changes: 1 addition & 1 deletion src/application/KeyValue.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class KeyValue extends PersistedObject {
static fromResource(resource) {
const keyValue = new KeyValue();
keyValue.key = resource.key;
keyValue.value = JSON.stringify(resource.value);
keyValue.value = typeof (resource.value) !== "string" ? JSON.stringify(resource.value): resource.value;
return keyValue;
}

Expand Down
7 changes: 7 additions & 0 deletions src/framework/RealmProxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ class RealmProxy {
return this.realmDb.close();
}

/**
*
* @param schemaName
* @param properties
* @param updateMode , all === true, modified , never === false
* @returns {*}
*/
create(schemaName, properties, updateMode = "never") {
const underlyingObject = _.isNil(properties.that) ? properties : properties.that;
const entityClass = this.entityMappingConfig.getEntityClass(schemaName);
Expand Down
1 change: 1 addition & 0 deletions test/EntitiesMetaDataTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ describe('EntitiesMetaDataTest', () => {
it('entitiesLoadedFromServer', () => {
var entitiesLoadedFromServer = EntityMetaData.entitiesLoadedFromServer();
assert.notIncludeMembers(entitiesLoadedFromServer, [Settings, Individual]);
assert.notIncludeMembers(entitiesLoadedFromServer, EntityMetaData.embeddedEntities());
});

describe('model', function () {
Expand Down

0 comments on commit 815110b

Please sign in to comment.