diff --git a/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/common.js b/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/common.js index 1038ca835aa09e234a67b6096f43092b68a02868..fc2529d454a6fb807d16233babdfb6436b278ba1 100644 --- a/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/common.js +++ b/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/common.js @@ -43,14 +43,18 @@ define([ 'jquery', 'openbis', 'underscore', 'test/dtos' ], function($, defaultOp this.ExternalDmsAddressType = require('as/dto/externaldms/ExternalDmsAddressType'); this.SpaceUpdate = dtos.SpaceUpdate; this.ProjectUpdate = dtos.ProjectUpdate; + this.ExperimentTypeUpdate = dtos.ExperimentTypeUpdate; this.ExperimentUpdate = dtos.ExperimentUpdate; + this.SampleTypeUpdate = dtos.SampleTypeUpdate; this.SampleUpdate = dtos.SampleUpdate; + this.DataSetTypeUpdate = dtos.DataSetTypeUpdate; this.DataSetUpdate = dtos.DataSetUpdate; this.PhysicalDataUpdate = dtos.PhysicalDataUpdate; this.LinkedDataUpdate = dtos.LinkedDataUpdate; this.SemanticAnnotationUpdate = dtos.SemanticAnnotationUpdate; this.ContentCopyListUpdateValue = dtos.ContentCopyListUpdateValue; this.DataStorePermId = dtos.DataStorePermId; + this.MaterialTypeUpdate = dtos.MaterialTypeUpdate; this.MaterialUpdate = dtos.MaterialUpdate; this.VocabularyTermUpdate = dtos.VocabularyTermUpdate; this.ExternalDmsUpdate = dtos.ExternalDmsUpdate; @@ -191,9 +195,13 @@ define([ 'jquery', 'openbis', 'underscore', 'test/dtos' ], function($, defaultOp this.UpdateSpacesOperation = dtos.UpdateSpacesOperation; this.UpdateProjectsOperation = dtos.UpdateProjectsOperation; this.UpdateExperimentsOperation = dtos.UpdateExperimentsOperation; + this.UpdateExperimentTypesOperation = dtos.UpdateExperimentTypesOperation; this.UpdateSamplesOperation = dtos.UpdateSamplesOperation; + this.UpdateSampleTypesOperation = dtos.UpdateSampleTypesOperation; this.UpdateDataSetsOperation = dtos.UpdateDataSetsOperation; + this.UpdateDataSetTypesOperation = dtos.UpdateDataSetTypesOperation; this.UpdateMaterialsOperation = dtos.UpdateMaterialsOperation; + this.UpdateMaterialTypesOperation = dtos.UpdateMaterialTypesOperation; this.UpdateVocabularyTermsOperation = dtos.UpdateVocabularyTermsOperation; this.UpdateExternalDmsOperation = dtos.UpdateExternalDmsOperation; this.UpdateTagsOperation = dtos.UpdateTagsOperation; diff --git a/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/dtos.js b/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/dtos.js index a6a16e17766be743be53431bcf8fb3b8f7327bb8..18edb6bd5250f7582a941b95ad8e2cb07b8b0d3a 100644 --- a/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/dtos.js +++ b/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/dtos.js @@ -230,11 +230,14 @@ var sources = [ 'as/dto/dataset/search/SearchDataSetTypesOperationResult', 'as/dto/dataset/StorageFormat', 'as/dto/dataset/update/DataSetUpdate', + 'as/dto/dataset/update/DataSetTypeUpdate', 'as/dto/dataset/update/ContentCopyListUpdateValue', 'as/dto/dataset/update/LinkedDataUpdate', 'as/dto/dataset/update/PhysicalDataUpdate', 'as/dto/dataset/update/UpdateDataSetsOperation', 'as/dto/dataset/update/UpdateDataSetsOperationResult', + 'as/dto/dataset/update/UpdateDataSetTypesOperation', + 'as/dto/dataset/update/UpdateDataSetTypesOperationResult', 'as/dto/datastore/DataStore', 'as/dto/datastore/fetchoptions/DataStoreFetchOptions', @@ -263,6 +266,7 @@ var sources = [ 'as/dto/entitytype/search/EntityKindSearchCriteria', 'as/dto/entitytype/search/EntityTypeSearchCriteria', 'as/dto/entitytype/EntityKind', + 'as/dto/entitytype/update/PropertyAssignmentListUpdateValue', 'as/dto/experiment/create/ExperimentCreation', 'as/dto/experiment/create/CreateExperimentsOperation', @@ -293,6 +297,9 @@ var sources = [ 'as/dto/experiment/update/ExperimentUpdate', 'as/dto/experiment/update/UpdateExperimentsOperation', 'as/dto/experiment/update/UpdateExperimentsOperationResult', + 'as/dto/experiment/update/ExperimentTypeUpdate', + 'as/dto/experiment/update/UpdateExperimentTypesOperation', + 'as/dto/experiment/update/UpdateExperimentTypesOperationResult', 'as/dto/externaldms/ExternalDms', 'as/dto/externaldms/delete/ExternalDmsDeletionOptions', @@ -357,6 +364,9 @@ var sources = [ 'as/dto/material/update/MaterialUpdate', 'as/dto/material/update/UpdateMaterialsOperation', 'as/dto/material/update/UpdateMaterialsOperationResult', + 'as/dto/material/update/MaterialTypeUpdate', + 'as/dto/material/update/UpdateMaterialTypesOperation', + 'as/dto/material/update/UpdateMaterialTypesOperationResult', 'as/dto/objectkindmodification/fetchoptions/ObjectKindModificationFetchOptions', 'as/dto/objectkindmodification/fetchoptions/ObjectKindModificationSortOptions', @@ -482,6 +492,9 @@ var sources = [ 'as/dto/sample/update/SampleUpdate', 'as/dto/sample/update/UpdateSamplesOperation', 'as/dto/sample/update/UpdateSamplesOperationResult', + 'as/dto/sample/update/SampleTypeUpdate', + 'as/dto/sample/update/UpdateSampleTypesOperation', + 'as/dto/sample/update/UpdateSampleTypesOperationResult', 'as/dto/service/CustomASService', 'as/dto/service/CustomASServiceExecutionOptions', diff --git a/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/openbis-execute-operations.js b/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/openbis-execute-operations.js index 329f9d96061748bc091d89782bc573a8a034b5c2..b782250f1b29a8cdf50cf08c8e75516558ba8069 100644 --- a/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/openbis-execute-operations.js +++ b/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/openbis-execute-operations.js @@ -165,18 +165,34 @@ define([ 'jquery', 'openbis', 'test/common' ], function($, openbis, common) { return this._executeUpdateOperation(new c.UpdateExperimentsOperation(updates)); } + this.updateExperimentTypes = function(updates) { + return this._executeUpdateOperation(new c.UpdateExperimentTypesOperation(updates)); + } + this.updateSamples = function(updates) { return this._executeUpdateOperation(new c.UpdateSamplesOperation(updates)); } + this.updateSampleTypes = function(updates) { + return this._executeUpdateOperation(new c.UpdateSampleTypesOperation(updates)); + } + this.updateDataSets = function(updates) { return this._executeUpdateOperation(new c.UpdateDataSetsOperation(updates)); } + this.updateDataSetTypes = function(updates) { + return this._executeUpdateOperation(new c.UpdateDataSetTypesOperation(updates)); + } + this.updateMaterials = function(updates) { return this._executeUpdateOperation(new c.UpdateMaterialsOperation(updates)); } + this.updateMaterialTypes = function(updates) { + return this._executeUpdateOperation(new c.UpdateMaterialTypesOperation(updates)); + } + this.updateVocabularyTerms = function(updates) { return this._executeUpdateOperation(new c.UpdateVocabularyTermsOperation(updates)); } diff --git a/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/test-update.js b/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/test-update.js index d19587f18def394c4ced0cb8a951b7fa88887bc2..788976f72f1732b1f32837a94a3a6ff8c3713ecd 100644 --- a/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/test-update.js +++ b/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/test-update.js @@ -157,10 +157,71 @@ define([ 'jquery', 'underscore', 'openbis', 'test/openbis-execute-operations', ' testUpdate(c, fCreate, fUpdate, c.findProject, null, fCheckError); }); + QUnit.test("updateExperimentTypes()", function(assert) { + var c = new common(assert, openbis); + var code = c.generateId("EXPERIMENT_TYPE"); + + var fCreate = function(facade) { + var assignmentCreation = new c.PropertyAssignmentCreation(); + assignmentCreation.setSection("test section"); + assignmentCreation.setOrdinal(10); + assignmentCreation.setPropertyTypeId(new c.PropertyTypePermId("DESCRIPTION")); + assignmentCreation.setPluginId(new c.PluginPermId("Diff_time")); + assignmentCreation.setInitialValueForExistingEntities("initial value"); + assignmentCreation.setShowInEditView(true); + assignmentCreation.setShowRawValueInForms(true); + + var creation = new c.ExperimentTypeCreation(); + creation.setCode(code); + creation.setDescription("a new description"); + creation.setPropertyAssignments([ assignmentCreation ]); + + return facade.createExperimentTypes([ creation ]); + } + + var fUpdate = function(facade, permId) { + var assignmentCreation = new c.PropertyAssignmentCreation(); + assignmentCreation.setSection("test section 2"); + assignmentCreation.setOrdinal(10); + assignmentCreation.setPropertyTypeId(new c.PropertyTypePermId("VERSION")); + assignmentCreation.setPluginId(new c.PluginPermId("Diff_time")); + assignmentCreation.setMandatory(true); + assignmentCreation.setInitialValueForExistingEntities("1.0"); + assignmentCreation.setShowInEditView(true); + assignmentCreation.setShowRawValueInForms(true); + var update = new c.ExperimentTypeUpdate(); + update.setTypeId(permId); + update.setDescription("another new description"); + update.setValidationPluginId(new c.PluginPermId("Has_Parents")); + update.getPropertyAssignments().set([assignmentCreation]); + return facade.updateExperimentTypes([ update ]); + } + + var fCheck = function(type) { + c.assertEqual(type.getCode(), code, "Type code"); + c.assertEqual(type.getPermId().getPermId(), code, "Type perm id"); + c.assertEqual(type.getDescription(), "another new description", "Description"); + + c.assertEqual(type.getPropertyAssignments().length, 1, "Assignments count"); + + var assignment = type.getPropertyAssignments()[0]; + + c.assertEqual(assignment.getSection(), "test section 2", "Assignment section"); + c.assertEqual(assignment.getOrdinal(), 10, "Assignment ordinal"); + c.assertEqual(assignment.getPropertyType().getCode(), "VERSION", "Assignment property type code"); + c.assertEqual(assignment.isMandatory(), true, "Assignment mandatory"); + c.assertEqual(assignment.isShowInEditView(), true, "Assignment ShowInEditView"); + c.assertEqual(assignment.isShowRawValueInForms(), true, "Assignment ShowRawValueInForms"); + } + + testUpdate(c, fCreate, fUpdate, c.findExperimentType, fCheck); + }); + + QUnit.test("updateExperiments() changed attributes + added tag + added attachment", function(assert) { var c = new common(assert, openbis); var code = c.generateId("EXPERIMENT"); - + var fCreate = function(facade) { var experimentCreation = new c.ExperimentCreation(); experimentCreation.setCode(code); @@ -170,7 +231,7 @@ define([ 'jquery', 'underscore', 'openbis', 'test/openbis-execute-operations', ' experimentCreation.setProjectId(new c.ProjectIdentifier("/TEST/TEST-PROJECT")); return facade.createExperiments([ experimentCreation ]); } - + var fUpdate = function(facade, permId) { var experimentUpdate = new c.ExperimentUpdate(); experimentUpdate.setExperimentId(permId); @@ -184,7 +245,7 @@ define([ 'jquery', 'underscore', 'openbis', 'test/openbis-execute-operations', ' experimentUpdate.getAttachments().add([ attachmentCreation ]); return facade.updateExperiments([ experimentUpdate ]); } - + var fCheck = function(experiment) { c.assertEqual(experiment.getCode(), code, "Experiment code"); c.assertEqual(experiment.getType().getCode(), "HT_SEQUENCING", "Type code"); @@ -201,10 +262,10 @@ define([ 'jquery', 'underscore', 'openbis', 'test/openbis-execute-operations', ' c.assertEqual(atob(attachments[0].content), "hello world", "Attachment content"); c.assertEqual(attachments.length, 1, "Number of attachments"); } - + testUpdate(c, fCreate, fUpdate, c.findExperiment, fCheck); }); - + QUnit.test("updateExperiments() changed properties + removed tag", function(assert) { var c = new common(assert, openbis); var code = c.generateId("EXPERIMENT"); @@ -267,10 +328,87 @@ define([ 'jquery', 'underscore', 'openbis', 'test/openbis-execute-operations', ' testUpdate(c, fCreate, fUpdate, c.findExperiment, null, fCheckError); }); + QUnit.test("updateSampleTypes()", function(assert) { + var c = new common(assert, openbis); + var code = c.generateId("SAMPLE_TYPE"); + + var fCreate = function(facade) { + var assignmentCreation = new c.PropertyAssignmentCreation(); + assignmentCreation.setSection("test section"); + assignmentCreation.setOrdinal(10); + assignmentCreation.setPropertyTypeId(new c.PropertyTypePermId("DESCRIPTION")); + assignmentCreation.setPluginId(new c.PluginPermId("Diff_time")); + assignmentCreation.setMandatory(true); + assignmentCreation.setInitialValueForExistingEntities("initial value"); + assignmentCreation.setShowInEditView(true); + assignmentCreation.setShowRawValueInForms(true); + + var creation = new c.SampleTypeCreation(); + creation.setCode(code); + creation.setDescription("a new description"); + creation.setGeneratedCodePrefix("TEST_PREFIX"); + creation.setPropertyAssignments([ assignmentCreation ]); + + return facade.createSampleTypes([ creation ]); + } + + var fUpdate = function(facade, permId) { + var assignmentCreation = new c.PropertyAssignmentCreation(); + assignmentCreation.setSection("test section 2"); + assignmentCreation.setOrdinal(10); + assignmentCreation.setPropertyTypeId(new c.PropertyTypePermId("VERSION")); + assignmentCreation.setPluginId(new c.PluginPermId("Diff_time")); + assignmentCreation.setMandatory(true); + assignmentCreation.setInitialValueForExistingEntities("1.0"); + assignmentCreation.setShowInEditView(true); + assignmentCreation.setShowRawValueInForms(true); + var update = new c.SampleTypeUpdate(); + update.setTypeId(permId); + update.setAutoGeneratedCode(true); + update.setSubcodeUnique(true); + update.setDescription("another new description"); + update.setGeneratedCodePrefix("TEST_PREFIX2"); + update.setListable(true); + update.setShowContainer(true); + update.setShowParents(true); + update.setShowParentMetadata(true); + update.setValidationPluginId(new c.PluginPermId("Has_Parents")); + update.getPropertyAssignments().add([assignmentCreation]); + update.getPropertyAssignments().remove([new c.PropertyAssignmentPermId(permId, new c.PropertyTypePermId("DESCRIPTION"))]); + return facade.updateSampleTypes([ update ]); + } + + var fCheck = function(type) { + c.assertEqual(type.getCode(), code, "Type code"); + c.assertEqual(type.getPermId().getPermId(), code, "Type perm id"); + c.assertEqual(type.getDescription(), "another new description", "Description"); + c.assertEqual(type.isAutoGeneratedCode(), true, "AutoGeneratedCode"); + c.assertEqual(type.isSubcodeUnique(), true, "SubcodeUnique"); + c.assertEqual(type.getGeneratedCodePrefix(), "TEST_PREFIX2", "GeneratedCodePrefix"); + c.assertEqual(type.isListable(), true, "Listable"); + c.assertEqual(type.isShowContainer(), true, "ShowContainer"); + c.assertEqual(type.isShowParents(), true, "ShowParents"); + c.assertEqual(type.isShowParentMetadata(), true, "ShowParentMetadata"); + + c.assertEqual(type.getPropertyAssignments().length, 1, "Assignments count"); + + var assignment = type.getPropertyAssignments()[0]; + + c.assertEqual(assignment.getSection(), "test section 2", "Assignment section"); + c.assertEqual(assignment.getOrdinal(), 10, "Assignment ordinal"); + c.assertEqual(assignment.getPropertyType().getCode(), "VERSION", "Assignment property type code"); + c.assertEqual(assignment.isMandatory(), true, "Assignment mandatory"); + c.assertEqual(assignment.isShowInEditView(), true, "Assignment ShowInEditView"); + c.assertEqual(assignment.isShowRawValueInForms(), true, "Assignment ShowRawValueInForms"); + } + + testUpdate(c, fCreate, fUpdate, c.findSampleType, fCheck); + }); + QUnit.test("updateSamples()", function(assert) { var c = new common(assert, openbis); var code = c.generateId("SAMPLE"); - + var fCreate = function(facade) { var creation = new c.SampleCreation(); creation.setTypeId(new c.EntityTypePermId("UNKNOWN")); @@ -279,7 +417,7 @@ define([ 'jquery', 'underscore', 'openbis', 'test/openbis-execute-operations', ' creation.setTagIds([ new c.TagCode("CREATE_JSON_TAG") ]); return facade.createSamples([ creation ]); } - + var fUpdate = function(facade, permId) { var update = new c.SampleUpdate(); update.setSampleId(permId); @@ -288,7 +426,7 @@ define([ 'jquery', 'underscore', 'openbis', 'test/openbis-execute-operations', ' update.getTagIds().add(new c.TagCode("CREATE_JSON_TAG_3")); return facade.updateSamples([ update ]); } - + var fCheck = function(sample) { c.assertEqual(sample.getCode(), code, "Sample code"); c.assertEqual(sample.getType().getCode(), "UNKNOWN", "Type code"); @@ -296,42 +434,109 @@ define([ 'jquery', 'underscore', 'openbis', 'test/openbis-execute-operations', ' c.assertObjectsCount(sample.getTags(), 2); c.assertObjectsWithValues(sample.getTags(), "code", [ "CREATE_JSON_TAG_2", "CREATE_JSON_TAG_3" ]); } - + testUpdate(c, fCreate, fUpdate, c.findSample, fCheck); }); + + QUnit.test("updateDataSetTypes()", function(assert) { + var c = new common(assert, openbis); + var code = c.generateId("DATA_SET_TYPE"); + + var fCreate = function(facade) { + var assignmentCreation = new c.PropertyAssignmentCreation(); + assignmentCreation.setSection("test section"); + assignmentCreation.setOrdinal(10); + assignmentCreation.setPropertyTypeId(new c.PropertyTypePermId("DESCRIPTION")); + assignmentCreation.setPluginId(new c.PluginPermId("Diff_time")); + assignmentCreation.setMandatory(true); + assignmentCreation.setInitialValueForExistingEntities("initial value"); + assignmentCreation.setShowInEditView(true); + assignmentCreation.setShowRawValueInForms(true); + + var creation = new c.DataSetTypeCreation(); + creation.setCode(code); + creation.setDescription("a new description"); + creation.setPropertyAssignments([ assignmentCreation ]); + + return facade.createDataSetTypes([ creation ]); + } + + var fUpdate = function(facade, permId) { + var assignmentCreation = new c.PropertyAssignmentCreation(); + assignmentCreation.setSection("test section 2"); + assignmentCreation.setOrdinal(10); + assignmentCreation.setPropertyTypeId(new c.PropertyTypePermId("VERSION")); + assignmentCreation.setPluginId(new c.PluginPermId("Diff_time")); + assignmentCreation.setMandatory(true); + assignmentCreation.setInitialValueForExistingEntities("1.0"); + assignmentCreation.setShowInEditView(true); + assignmentCreation.setShowRawValueInForms(true); + var update = new c.DataSetTypeUpdate(); + update.setTypeId(permId); + update.setDescription("another new description"); + update.setValidationPluginId(new c.PluginPermId("Has_Parents")); + update.setMainDataSetPattern(".*\\.jpg"); + update.setMainDataSetPath("original/images/"); + update.setDisallowDeletion(true); + update.getPropertyAssignments().set([assignmentCreation]); + return facade.updateDataSetTypes([ update ]); + } + + var fCheck = function(type) { + c.assertEqual(type.getCode(), code, "Type code"); + c.assertEqual(type.getPermId().getPermId(), code, "Type perm id"); + c.assertEqual(type.getDescription(), "another new description", "Description"); + c.assertEqual(type.getMainDataSetPattern(), ".*\\.jpg", "Main data set pattern"); + c.assertEqual(type.getMainDataSetPath(), "original/images/", "Main data set path"); + c.assertEqual(type.isDisallowDeletion(), true, "Disallow deletion"); + + c.assertEqual(type.getPropertyAssignments().length, 1, "Assignments count"); + + var assignment = type.getPropertyAssignments()[0]; + + c.assertEqual(assignment.getSection(), "test section 2", "Assignment section"); + c.assertEqual(assignment.getOrdinal(), 10, "Assignment ordinal"); + c.assertEqual(assignment.getPropertyType().getCode(), "VERSION", "Assignment property type code"); + c.assertEqual(assignment.isMandatory(), true, "Assignment mandatory"); + c.assertEqual(assignment.isShowInEditView(), true, "Assignment ShowInEditView"); + c.assertEqual(assignment.isShowRawValueInForms(), true, "Assignment ShowRawValueInForms"); + } + + testUpdate(c, fCreate, fUpdate, c.findDataSetType, fCheck); + }); QUnit.test("updateDataSets()", function(assert) { var c = new common(assert, openbis); var code = null; - + var fCreate = function(facade) { return c.createDataSet(facade).then(function(permId) { code = permId.getPermId(); return [ permId ]; }); } - + var fUpdate = function(facade, permId) { var physicalUpdate = new c.PhysicalDataUpdate(); physicalUpdate.setFileFormatTypeId(new c.FileFormatTypePermId("TIFF")); - + var update = new c.DataSetUpdate(); update.setDataSetId(permId); update.setProperty("NOTES", "new 409 description"); update.setPhysicalData(physicalUpdate); - + return facade.updateDataSets([ update ]); } - + var fCheck = function(dataSet) { c.assertEqual(dataSet.getCode(), code, "Code"); c.assertEqual(dataSet.getProperties()["NOTES"], "new 409 description", "Property NOTES"); c.assertEqual(dataSet.getPhysicalData().getFileFormatType().getCode(), "TIFF", "File format type"); } - + testUpdate(c, fCreate, fUpdate, c.findDataSet, fCheck); }); - + QUnit.test("updateDataSets() link data set", function(assert) { var c = new common(assert, openbis); var code = "20160613195437233-437"; @@ -409,10 +614,72 @@ define([ 'jquery', 'underscore', 'openbis', 'test/openbis-execute-operations', ' testUpdate(c, fCreate, fUpdate, c.findDataSet, fCheck); }); + QUnit.test("updateMaterialTypes()", function(assert) { + var c = new common(assert, openbis); + var code = c.generateId("MATERIAL_TYPE"); + + var fCreate = function(facade) { + var assignmentCreation = new c.PropertyAssignmentCreation(); + assignmentCreation.setSection("test section"); + assignmentCreation.setOrdinal(10); + assignmentCreation.setPropertyTypeId(new c.PropertyTypePermId("DESCRIPTION")); + assignmentCreation.setPluginId(new c.PluginPermId("Diff_time")); + assignmentCreation.setMandatory(true); + assignmentCreation.setInitialValueForExistingEntities("initial value"); + assignmentCreation.setShowInEditView(true); + assignmentCreation.setShowRawValueInForms(true); + + var creation = new c.MaterialTypeCreation(); + creation.setCode(code); + creation.setDescription("a new description"); + creation.setPropertyAssignments([ assignmentCreation ]); + + return facade.createMaterialTypes([ creation ]); + } + + var fUpdate = function(facade, permId) { + var assignmentCreation = new c.PropertyAssignmentCreation(); + assignmentCreation.setSection("test section 2"); + assignmentCreation.setOrdinal(10); + assignmentCreation.setPropertyTypeId(new c.PropertyTypePermId("VERSION")); + assignmentCreation.setPluginId(new c.PluginPermId("Diff_time")); + assignmentCreation.setMandatory(true); + assignmentCreation.setInitialValueForExistingEntities("1.0"); + assignmentCreation.setShowInEditView(true); + assignmentCreation.setShowRawValueInForms(true); + var update = new c.MaterialTypeUpdate(); + update.setTypeId(permId); + update.setDescription("another new description"); + update.setValidationPluginId(new c.PluginPermId("Has_Parents")); + update.getPropertyAssignments().add([assignmentCreation]); + update.getPropertyAssignments().remove([new c.PropertyAssignmentPermId(permId, new c.PropertyTypePermId("DESCRIPTION"))]); + return facade.updateMaterialTypes([ update ]); + } + + var fCheck = function(type) { + c.assertEqual(type.getCode(), code, "Type code"); + c.assertEqual(type.getPermId().getPermId(), code, "Type perm id"); + c.assertEqual(type.getDescription(), "another new description", "Description"); + + c.assertEqual(type.getPropertyAssignments().length, 1, "Assignments count"); + + var assignment = type.getPropertyAssignments()[0]; + + c.assertEqual(assignment.getSection(), "test section 2", "Assignment section"); + c.assertEqual(assignment.getOrdinal(), 10, "Assignment ordinal"); + c.assertEqual(assignment.getPropertyType().getCode(), "VERSION", "Assignment property type code"); + c.assertEqual(assignment.isMandatory(), true, "Assignment mandatory"); + c.assertEqual(assignment.isShowInEditView(), true, "Assignment ShowInEditView"); + c.assertEqual(assignment.isShowRawValueInForms(), true, "Assignment ShowRawValueInForms"); + } + + testUpdate(c, fCreate, fUpdate, c.findMaterialType, fCheck); + }); + QUnit.test("updateMaterials()", function(assert) { var c = new common(assert, openbis); var code = c.generateId("MATERIAL"); - + var fCreate = function(facade) { var materialCreation = new c.MaterialCreation(); materialCreation.setTypeId(new c.EntityTypePermId("COMPOUND")); @@ -420,24 +687,24 @@ define([ 'jquery', 'underscore', 'openbis', 'test/openbis-execute-operations', ' materialCreation.setProperty("DESCRIPTION", "Metal"); return facade.createMaterials([ materialCreation ]); } - + var fUpdate = function(facade, permId) { var materialUpdate = new c.MaterialUpdate(); materialUpdate.setMaterialId(permId); materialUpdate.setProperty("DESCRIPTION", "Alloy"); return facade.updateMaterials([ materialUpdate ]); } - + var fCheck = function(material) { c.assertEqual(material.getCode(), code, "Material code"); c.assertEqual(material.getType().getCode(), "COMPOUND", "Type code"); var properties = material.getProperties(); c.assertEqual(properties["DESCRIPTION"], "Alloy", "Property DESCRIPTION"); } - + testUpdate(c, fCreate, fUpdate, c.findMaterial, fCheck); }); - + QUnit.test("updateVocabularyTerms()", function(assert) { var c = new common(assert, openbis); var code = c.generateId("VOCABULARY_TERM");