diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/amc/AddPropertyTypeDialog.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/amc/AddPropertyTypeDialog.java index e585c26fcdc94bdbcc1f411fdcb624b4e9463907..9e7ac0b959cd96a7ed7ce4b243ccf6c0921b7c39 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/amc/AddPropertyTypeDialog.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/amc/AddPropertyTypeDialog.java @@ -46,6 +46,7 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.field.X import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.material.MaterialTypeSelectionWidget; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.property_type.DataTypeSelectionWidget; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.property_type.EntityTypePropertyTypeSelectionWidget; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.property_type.PropertyTypeAssignmentGrid.InMemoryGridAddCallback; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.property_type.PropertyTypeSelectionWidget; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.property_type.SectionSelectionWidget; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.sample.SampleTypeSelectionWidget; @@ -63,7 +64,6 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.EntityTypePropertyType; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ExperimentType; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.MaterialType; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.NewETPTAssignment; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.NewPTNewAssigment; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.PropertyType; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.SampleType; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ScriptType; @@ -205,19 +205,19 @@ public class AddPropertyTypeDialog extends AbstractRegistrationDialog // // Save Property Type on memory // - List<NewPTNewAssigment> propertyTypes; + InMemoryGridAddCallback inMemoryGridCallback; // // Constructor and Init Methods // public AddPropertyTypeDialog(final IViewContext<ICommonClientServiceAsync> viewContext, final IDelegatedAction postRegistrationCallback, EntityKind entityKind, - String entityCode, List<NewPTNewAssigment> propertyTypes) + String entityCode, InMemoryGridAddCallback inMemoryGridCallback) { super(viewContext, viewContext.getMessage(Dict.PROPERTY_TYPE_REGISTRATION), postRegistrationCallback); this.viewContext = viewContext; - this.propertyTypes = propertyTypes; + this.inMemoryGridCallback = inMemoryGridCallback; this.entityKind = entityKind; setWidth(FORM_WIDTH); @@ -364,7 +364,7 @@ public class AddPropertyTypeDialog extends AbstractRegistrationDialog getPropertyTypeSelectionWidget().enable(); getPropertyTypeSelectionWidget().setVisible(true); - if(propertyTypes == null) { + if(inMemoryGridCallback == null) { addField(getEntityTypeSelectionWidget()); getEntityTypeSelectionWidget().disable(); getEntityTypeSelectionWidget().setVisible(false); @@ -422,7 +422,7 @@ public class AddPropertyTypeDialog extends AbstractRegistrationDialog getPropertyTypeSelectionWidget().disable(); getPropertyTypeSelectionWidget().setVisible(false); - if(propertyTypes == null) { + if(inMemoryGridCallback == null) { addField(getEntityTypeSelectionWidget()); getEntityTypeSelectionWidget().disable(); getEntityTypeSelectionWidget().setVisible(false); @@ -455,7 +455,7 @@ public class AddPropertyTypeDialog extends AbstractRegistrationDialog @Override protected void register(final AsyncCallback<Void> registrationCallback) { - if(propertyTypes == null) { + if(inMemoryGridCallback == null) { if (false == isSelect()) { final PropertyType propertyType = createPropertyType(); @@ -469,19 +469,19 @@ public class AddPropertyTypeDialog extends AbstractRegistrationDialog new AssignPropertyTypeCallback(viewContext, registrationCallback)); } } else { - NewPTNewAssigment propertyType = new NewPTNewAssigment(); + boolean isExixtingPropertyType = isSelect(); + PropertyType propertyType = null; + NewETPTAssignment assignment = createAssignment(); + if (false == isSelect()) { - propertyType.setExistingPropertyType(false); - propertyType.setPropertyType(createPropertyType()); - propertyType.setAssignment(createAssignment()); + propertyType = createPropertyType(); } else { - propertyType.setExistingPropertyType(true); - propertyType.setPropertyType(propertyTypeSelectionWidget.tryGetSelectedPropertyType()); - propertyType.setAssignment(createAssignment()); + propertyType = propertyTypeSelectionWidget.tryGetSelectedPropertyType(); } - propertyTypes.add(propertyType); + + inMemoryGridCallback.callback(isExixtingPropertyType, propertyType, assignment); this.close(); } } @@ -543,7 +543,7 @@ public class AddPropertyTypeDialog extends AbstractRegistrationDialog { //This code field can only be assigend here if the entity type exists. String entityTypeCode = null; - if(propertyTypes == null) { + if(inMemoryGridCallback == null) { entityTypeCode = ((EntityType) getEntityTypeSelectionWidget().tryGetSelected()).getCode(); } @@ -858,7 +858,7 @@ public class AddPropertyTypeDialog extends AbstractRegistrationDialog propertyType = this.createPropertyType(); } - if(propertyTypes == null) { + if(inMemoryGridCallback == null) { final EntityType entityType = (EntityType) getEntityTypeSelectionWidget().tryGetSelected(); if (propertyType != null && entityType != null && propertyType.getDataType() != null) { diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/entity_type/NewEntityTypeForm.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/entity_type/NewEntityTypeForm.java index 1152ee412840dbc61a1c1c203c0d25a89c2c9d46..9d1de048dda294a35691437be679bbd8e53ec3d9 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/entity_type/NewEntityTypeForm.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/entity_type/NewEntityTypeForm.java @@ -101,7 +101,7 @@ public class NewEntityTypeForm extends ContentPanel add(dialogForm, BorderLayoutDataFactory.create(LayoutRegion.NORTH, 350)); // Central panel - PropertyTypeAssignmentGrid grid = (PropertyTypeAssignmentGrid) PropertyTypeAssignmentGrid.create(viewContext, newTypeWithAssigments.getEntity(), newTypeWithAssigments.getAssigments()).getComponent(); + PropertyTypeAssignmentGrid grid = (PropertyTypeAssignmentGrid) PropertyTypeAssignmentGrid.create(viewContext, null, newTypeWithAssigments).getComponent(); final Component centerPanel = grid; add(centerPanel, BorderLayoutDataFactory.create(LayoutRegion.CENTER, 170)); diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/property_type/PropertyTypeAssignmentGrid.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/property_type/PropertyTypeAssignmentGrid.java index 7bb344231eccca34ee1a71c158af8bb0a3de1aba..5bcedb4c01792a54613bb5e9643df6f332621efb 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/property_type/PropertyTypeAssignmentGrid.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/property_type/PropertyTypeAssignmentGrid.java @@ -51,8 +51,10 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DatabaseModificationKin import ch.systemsx.cisd.openbis.generic.shared.basic.dto.EntityKind; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.EntityType; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.EntityTypePropertyType; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.NewETNewPTAssigments; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.NewETPTAssignment; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.NewPTNewAssigment; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.PropertyType; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Script; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ScriptType; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.TableModelRowWithObject; @@ -186,20 +188,24 @@ public class PropertyTypeAssignmentGrid extends TypedTableGrid<EntityTypePropert } } - public static IDisposableComponent create(final IViewContext<ICommonClientServiceAsync> viewContext, EntityType entity, List<NewPTNewAssigment> propertyTypes) + public static IDisposableComponent create(final IViewContext<ICommonClientServiceAsync> viewContext, EntityType entity, + NewETNewPTAssigments newTypeWithAssigments) { - return new PropertyTypeAssignmentGrid(viewContext, entity, propertyTypes).asDisposableWithoutToolbar(); + return new PropertyTypeAssignmentGrid(viewContext, entity, newTypeWithAssigments).asDisposableWithoutToolbar(); } private final IDelegatedAction postRegistrationCallback; + private final EntityType entity; - private final List<NewPTNewAssigment> propertyTypes; - - private PropertyTypeAssignmentGrid(final IViewContext<ICommonClientServiceAsync> viewContext, EntityType entity, List<NewPTNewAssigment> propertyTypes) + + private final NewETNewPTAssigments newTypeWithAssigments; + + private PropertyTypeAssignmentGrid(final IViewContext<ICommonClientServiceAsync> viewContext, EntityType entity, + NewETNewPTAssigments newTypeWithAssigments) { super(viewContext, BROWSER_ID, true, DisplayTypeIDGenerator.PROPERTY_TYPE_ASSIGNMENT_BROWSER_GRID); this.entity = entity; - this.propertyTypes = propertyTypes; + this.newTypeWithAssigments = newTypeWithAssigments; extendBottomToolbar(); postRegistrationCallback = createRefreshGridAction(); } @@ -208,7 +214,10 @@ public class PropertyTypeAssignmentGrid extends TypedTableGrid<EntityTypePropert { addEntityOperationsLabel(); - if(entity != null) { //View showing only property types for one type allow to add new properties + // + // Buttons used by the in memory grid form to create new entity types + // + if (newTypeWithAssigments != null) { final EntityType addEntity = this.entity; final Button addButton = new Button(viewContext.getMessage(Dict.BUTTON_ADD, ""), @@ -217,62 +226,133 @@ public class PropertyTypeAssignmentGrid extends TypedTableGrid<EntityTypePropert @Override public void componentSelected(ButtonEvent ce) { - AddPropertyTypeDialog dialog = new AddPropertyTypeDialog(viewContext, createRefreshGridAction(), addEntity.getEntityKind(), addEntity.getCode(), propertyTypes); + AddPropertyTypeDialog dialog = new AddPropertyTypeDialog( + viewContext, + createRefreshGridAction(), + newTypeWithAssigments.getEntity().getEntityKind(), + newTypeWithAssigments.getEntity().getCode(), + new InMemoryGridAddCallback() + ); dialog.show(); } }); addButton.setId(GRID_ID + "-add"); addButton(addButton); - } - - Button editButton = - createSelectedItemButton( - viewContext.getMessage(Dict.BUTTON_EDIT), - new ISelectedEntityInvoker<BaseEntityModel<TableModelRowWithObject<EntityTypePropertyType<?>>>>() + + Button removeButton = createSelectedItemButton("remove", new ISelectedEntityInvoker<BaseEntityModel<TableModelRowWithObject<EntityTypePropertyType<?>>>>() + { + @Override + public void invoke(BaseEntityModel<TableModelRowWithObject<EntityTypePropertyType<?>>> selectedItem,boolean keyPressed) { + final EntityTypePropertyType<?> etpt = selectedItem.getBaseObject().getObjectOrNull(); + (new InMemoryGridRemoveCallback()).callback(etpt); + } - @Override - public void invoke( - BaseEntityModel<TableModelRowWithObject<EntityTypePropertyType<?>>> selectedItem, - boolean keyPressed) + }); + removeButton.setId(GRID_ID + "-remove"); + addButton(removeButton); + } + + // + // Button used by the entity types grids + // + if (entity != null) + { // View showing only property types for one type allow to add new properties + final EntityType addEntity = this.entity; + final Button addButton = + new Button(viewContext.getMessage(Dict.BUTTON_ADD, ""), + new SelectionListener<ButtonEvent>() { - final EntityTypePropertyType<?> etpt = - selectedItem.getBaseObject().getObjectOrNull(); - if (etpt.isManagedInternally()) - { - final String errorMsg = - "Assignments of internally managed property types cannot be edited."; - MessageBox.alert("Error", errorMsg, null); - } else + @Override + public void componentSelected(ButtonEvent ce) { - createEditDialog(etpt).show(); + AddPropertyTypeDialog dialog = + new AddPropertyTypeDialog(viewContext, createRefreshGridAction(), addEntity.getEntityKind(), + addEntity.getCode(), null); + dialog.show(); } - } - }); - editButton.setId(GRID_ID + "-edit"); - addButton(editButton); + }); + addButton.setId(GRID_ID + "-add"); + addButton(addButton); + } - Button releaseButton = - createSelectedItemButton( - viewContext.getMessage(Dict.UNASSIGN_BUTTON_LABEL), - new ISelectedEntityInvoker<BaseEntityModel<TableModelRowWithObject<EntityTypePropertyType<?>>>>() + // + // Buttons used by the entity types grids and propertyes browser + // + if (newTypeWithAssigments == null) + { + Button editButton = createSelectedItemButton( + viewContext.getMessage(Dict.BUTTON_EDIT), + new ISelectedEntityInvoker<BaseEntityModel<TableModelRowWithObject<EntityTypePropertyType<?>>>>() + { + + @Override + public void invoke( + BaseEntityModel<TableModelRowWithObject<EntityTypePropertyType<?>>> selectedItem, + boolean keyPressed) { - @Override - public void invoke( - BaseEntityModel<TableModelRowWithObject<EntityTypePropertyType<?>>> selectedItem, - boolean keyPressed) + final EntityTypePropertyType<?> etpt = + selectedItem.getBaseObject().getObjectOrNull(); + if (etpt.isManagedInternally()) { - final EntityTypePropertyType<?> etpt = - selectedItem.getBaseObject().getObjectOrNull(); - unassignPropertyType(etpt); + final String errorMsg = + "Assignments of internally managed property types cannot be edited."; + MessageBox.alert("Error", errorMsg, null); + } else + { + createEditDialog(etpt).show(); } + } + }); + editButton.setId(GRID_ID + "-edit"); + addButton(editButton); - }); - releaseButton.setId(GRID_ID + "-release"); - addButton(releaseButton); + Button releaseButton = createSelectedItemButton( + viewContext.getMessage(Dict.UNASSIGN_BUTTON_LABEL), + new ISelectedEntityInvoker<BaseEntityModel<TableModelRowWithObject<EntityTypePropertyType<?>>>>() + { + @Override + public void invoke( + BaseEntityModel<TableModelRowWithObject<EntityTypePropertyType<?>>> selectedItem, + boolean keyPressed) + { + final EntityTypePropertyType<?> etpt = + selectedItem.getBaseObject().getObjectOrNull(); + unassignPropertyType(etpt); + } + }); + releaseButton.setId(GRID_ID + "-release"); + addButton(releaseButton); + } + addEntityOperationsSeparator(); } + + public class InMemoryGridRemoveCallback { + public void callback(final EntityTypePropertyType<?> etpt) { + for(int i = 0; i < newTypeWithAssigments.getAssigments().size(); i++) { + if(newTypeWithAssigments.getAssigments().get(i).getPropertyType().getCode().equals(etpt.getPropertyType().getCode())) { + newTypeWithAssigments.getAssigments().remove(i); + break; + } + } + newTypeWithAssigments.refreshOrder(); + refresh(); + } + } + + public class InMemoryGridAddCallback { + public void callback(boolean isExixtingPropertyType, PropertyType propertyType, NewETPTAssignment assignment) { + NewPTNewAssigment newPTNewAssigment = new NewPTNewAssigment(); + newPTNewAssigment.setExistingPropertyType(isExixtingPropertyType); + newPTNewAssigment.setPropertyType(propertyType); + newPTNewAssigment.setAssignment(assignment); + newTypeWithAssigments.getAssigments().add(newPTNewAssigment); + newTypeWithAssigments.refreshOrder(); + refresh(); + } + } private static ScriptChooserField createScriptChooserField( final IViewContext<ICommonClientServiceAsync> viewContext, String initialValue, @@ -592,28 +672,30 @@ public class PropertyTypeAssignmentGrid extends TypedTableGrid<EntityTypePropert DefaultResultSetConfig<String, TableModelRowWithObject<EntityTypePropertyType<?>>> resultSetConfig, final AbstractAsyncCallback<TypedTableResultSet<EntityTypePropertyType<?>>> callback) { - - AbstractAsyncCallback<TypedTableResultSet<EntityTypePropertyType<?>>> extendedCallback = - new AbstractAsyncCallback<TypedTableResultSet<EntityTypePropertyType<?>>>( - viewContext) + + AbstractAsyncCallback<TypedTableResultSet<EntityTypePropertyType<?>>> extendedCallback = + new AbstractAsyncCallback<TypedTableResultSet<EntityTypePropertyType<?>>>( + viewContext) + { + @Override + protected void process(TypedTableResultSet<EntityTypePropertyType<?>> result) { - @Override - protected void process(TypedTableResultSet<EntityTypePropertyType<?>> result) - { - callback.onSuccess(result); - } + callback.onSuccess(result); + } - @Override - public void finishOnFailure(Throwable caught) - { - callback.finishOnFailure(caught); - } + @Override + public void finishOnFailure(Throwable caught) + { + callback.finishOnFailure(caught); + } - }; - if(propertyTypes == null) { + }; + if (newTypeWithAssigments == null) + { viewContext.getService().listPropertyTypeAssignments(resultSetConfig, entity, extendedCallback); - } else { - viewContext.getService().listPropertyTypeAssignmentsFromBrowser(resultSetConfig, entity, propertyTypes, extendedCallback); + } else + { + viewContext.getService().listPropertyTypeAssignmentsFromBrowser(resultSetConfig, newTypeWithAssigments.getEntity(), newTypeWithAssigments.getAssigments(), extendedCallback); } } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/resultset/EntityTypePropertyTypeBrowserProvider.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/resultset/EntityTypePropertyTypeBrowserProvider.java index 077c5f658fcc8f80147a098ebd62fc1f9e2cae74..2e58ce4631b9307ec6ad377bf33a32bb2a245604 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/resultset/EntityTypePropertyTypeBrowserProvider.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/resultset/EntityTypePropertyTypeBrowserProvider.java @@ -32,21 +32,14 @@ import static ch.systemsx.cisd.openbis.generic.client.web.client.dto.PropertyTyp import java.util.List; -import ch.systemsx.cisd.openbis.generic.client.web.server.resultset.AbstractCommonTableModelProvider; import ch.systemsx.cisd.openbis.generic.shared.basic.SimpleYesNoRenderer; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetTypePropertyType; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataTypeCode; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.EntityType; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.EntityTypePropertyType; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ExperimentTypePropertyType; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.MaterialType; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.MaterialTypePropertyType; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.NewETNewPTAssigments; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.NewPTNewAssigment; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.PropertyType; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.SampleTypePropertyType; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Script; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.TypedTableModel; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Vocabulary; import ch.systemsx.cisd.openbis.generic.shared.util.TypedTableModelBuilder; /** @@ -54,17 +47,13 @@ import ch.systemsx.cisd.openbis.generic.shared.util.TypedTableModelBuilder; * * @author Juan Fuentes */ -public class EntityTypePropertyTypeBrowserProvider extends AbstractCommonTableModelProvider<EntityTypePropertyType<?>> +public class EntityTypePropertyTypeBrowserProvider extends EntityTypePropertyTypeProvider { - - private final EntityType entity; - private final List<NewPTNewAssigment> propertyTypesAsgs; public EntityTypePropertyTypeBrowserProvider(EntityType entity, List<NewPTNewAssigment> propertyTypesAsgs) { - super(null, null); - this.entity = entity; + super(null, null, entity); this.propertyTypesAsgs = propertyTypesAsgs; } @@ -91,35 +80,7 @@ public class EntityTypePropertyTypeBrowserProvider extends AbstractCommonTableMo // // Create EntityTypePropertyType from Browser in memory structure // - EntityTypePropertyType<?> etpt = null; - switch (entity.getEntityKind()) - { - case SAMPLE: - etpt = new SampleTypePropertyType(); - break; - case EXPERIMENT: - etpt = new ExperimentTypePropertyType(); - break; - case DATA_SET: - etpt = new DataSetTypePropertyType(); - break; - case MATERIAL: - etpt = new MaterialTypePropertyType(); - break; - } - etpt.setPropertyType(propertyTypeAsg.getPropertyType()); - etpt.setOrdinal(propertyTypeAsg.getAssignment().getOrdinal()); //TO-DO Sort list by order - etpt.setSection(propertyTypeAsg.getAssignment().getSection()); - etpt.setMandatory(propertyTypeAsg.getAssignment().isMandatory()); - etpt.setDynamic(propertyTypeAsg.getAssignment().isDynamic()); - etpt.setManaged(propertyTypeAsg.getAssignment().isManaged()); - etpt.setShownInEditView(propertyTypeAsg.getAssignment().isShownInEditView()); - etpt.setShowRawValue(propertyTypeAsg.getAssignment().getShowRawValue()); - if(propertyTypeAsg.getAssignment().getScriptName() != null) { - Script scriptNew = new Script(); - scriptNew.setName(propertyTypeAsg.getAssignment().getScriptName()); - etpt.setScript(scriptNew); - } + EntityTypePropertyType<?> etpt = NewETNewPTAssigments.getEntityTypePropertyType(entity.getEntityKind(), propertyTypeAsg); // // Create Row @@ -147,47 +108,4 @@ public class EntityTypePropertyTypeBrowserProvider extends AbstractCommonTableMo return builder.getModel(); } - private static String renderDataType(PropertyType entity) - { - DataTypeCode dataType = entity.getDataType().getCode(); - switch (dataType) - { - case BOOLEAN: - return "True / False"; - case CONTROLLEDVOCABULARY: - return "Vocabulary: " + tryGetVocabularyCode(entity); - case INTEGER: - return "Integer Number"; - case MATERIAL: - String materialTypeCode = tryGetMaterialTypeCode(entity); - if (materialTypeCode == null) - { - return "Material of Any Type"; - } else - { - return "Material of Type: " + materialTypeCode; - } - case REAL: - return "Float Number"; - case TIMESTAMP: - return "Date and Time"; - case VARCHAR: - return "Text"; - default: - return dataType.name(); - } - } - - private static String tryGetVocabularyCode(PropertyType entity) - { - Vocabulary vocabulary = entity.getVocabulary(); - return vocabulary != null ? vocabulary.getCode() : null; - } - - private static String tryGetMaterialTypeCode(PropertyType entity) - { - MaterialType materialType = entity.getMaterialType(); - return materialType != null ? materialType.getCode() : null; - } - } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/resultset/EntityTypePropertyTypeProvider.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/resultset/EntityTypePropertyTypeProvider.java index f0af5a585b915b24d0052742dcad52504dc4b118..155bd001fea54dc3072c12e87f1b80b9a0a38171 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/resultset/EntityTypePropertyTypeProvider.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/resultset/EntityTypePropertyTypeProvider.java @@ -55,7 +55,7 @@ public class EntityTypePropertyTypeProvider extends AbstractCommonTableModelProvider<EntityTypePropertyType<?>> { - private final EntityType entity; + protected final EntityType entity; public EntityTypePropertyTypeProvider(ICommonServer commonServer, String sessionToken, EntityType entity) @@ -125,7 +125,7 @@ public class EntityTypePropertyTypeProvider extends return builder.getModel(); } - private static String renderDataType(PropertyType entity) + protected static String renderDataType(PropertyType entity) { DataTypeCode dataType = entity.getDataType().getCode(); switch (dataType) @@ -156,13 +156,13 @@ public class EntityTypePropertyTypeProvider extends } } - private static String tryGetVocabularyCode(PropertyType entity) + protected static String tryGetVocabularyCode(PropertyType entity) { Vocabulary vocabulary = entity.getVocabulary(); return vocabulary != null ? vocabulary.getCode() : null; } - private static String tryGetMaterialTypeCode(PropertyType entity) + protected static String tryGetMaterialTypeCode(PropertyType entity) { MaterialType materialType = entity.getMaterialType(); return materialType != null ? materialType.getCode() : null; diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/NewETNewPTAssigments.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/NewETNewPTAssigments.java index ba9ebbc62221741b22ba643ef39ee7b05aadca43..1648549787d97428781bff8b8c9d2261436648a8 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/NewETNewPTAssigments.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/NewETNewPTAssigments.java @@ -29,4 +29,114 @@ public class NewETNewPTAssigments implements Serializable this.assigments = assigments; } + + public void refreshOrder() { +// // +// // Get List +// // +// List<? extends EntityTypePropertyType<?>> list = entity.getAssignedPropertyTypes(); +// +// switch (entity.getEntityKind()) +// { +// case SAMPLE: +// SampleType sampleType = (SampleType) entity; +// if(entity.getAssignedPropertyTypes() == null) { +// sampleType.setSampleTypePropertyTypes(new ArrayList<SampleTypePropertyType>()); +// } +// entity.getAssignedPropertyTypes().clear(); +// break; +// case EXPERIMENT: +// ExperimentType experimentType = (ExperimentType) entity; +// if(entity.getAssignedPropertyTypes() == null) { +// experimentType.setExperimentTypePropertyTypes(new ArrayList<ExperimentTypePropertyType>()); +// } +// entity.getAssignedPropertyTypes().clear(); +// break; +// case DATA_SET: +// DataSetType datasetType = (DataSetType) entity; +// if(entity.getAssignedPropertyTypes() == null) { +// datasetType.setDataSetTypePropertyTypes(new ArrayList<DataSetTypePropertyType>()); +// } +// entity.getAssignedPropertyTypes().clear(); +// break; +// case MATERIAL: +// MaterialType materialType = (MaterialType) entity; +// if(entity.getAssignedPropertyTypes() == null) { +// materialType.setMaterialTypePropertyTypes(new ArrayList<MaterialTypePropertyType>()); +// } +// entity.getAssignedPropertyTypes().clear(); +// break; +// } +// +// // +// // Update List +// // +// for(int i = 0; i < assigments.size(); i++) { +// NewPTNewAssigment assigment = assigments.get(i); +// int insertPos = -1; +// EntityTypePropertyType<?> etpt = getEntityTypePropertyType(entity.getEntityKind(), assigment); +// +// if(assigment.getAssignment().getOrdinal() == 0) { +// insertPos = 0; +// } else if (assigment.getAssignment().getOrdinal() != 0) { +// insertPos = i; +// } +// etpt.setOrdinal(insertPos+1L); +// +// switch (entity.getEntityKind()) +// { +// case SAMPLE: +// SampleType sampleType = (SampleType) entity; +// sampleType.getAssignedPropertyTypes().add(insertPos, (SampleTypePropertyType) etpt); +// break; +// case EXPERIMENT: +// ExperimentType experimentType = (ExperimentType) entity; +// experimentType.getAssignedPropertyTypes().add(insertPos, (ExperimentTypePropertyType) etpt); +// break; +// case DATA_SET: +// DataSetType datasetType = (DataSetType) entity; +// datasetType.getAssignedPropertyTypes().add(insertPos, (DataSetTypePropertyType) etpt); +// break; +// case MATERIAL: +// MaterialType materialType = (MaterialType) entity; +// materialType.getAssignedPropertyTypes().add(insertPos, (MaterialTypePropertyType) etpt); +// break; +// } +// } + } + + public static EntityTypePropertyType<?> getEntityTypePropertyType(EntityKind kind, NewPTNewAssigment propertyTypeAsg) { + EntityTypePropertyType<?> etpt = null; + switch (kind) + { + case SAMPLE: + etpt = new SampleTypePropertyType(); + break; + case EXPERIMENT: + etpt = new ExperimentTypePropertyType(); + break; + case DATA_SET: + etpt = new DataSetTypePropertyType(); + break; + case MATERIAL: + etpt = new MaterialTypePropertyType(); + break; + } + etpt.setPropertyType(propertyTypeAsg.getPropertyType()); + etpt.setOrdinal(propertyTypeAsg.getAssignment().getOrdinal()); //TO-DO Sort list by order + etpt.setSection(propertyTypeAsg.getAssignment().getSection()); + etpt.setMandatory(propertyTypeAsg.getAssignment().isMandatory()); + etpt.setDynamic(propertyTypeAsg.getAssignment().isDynamic()); + etpt.setManaged(propertyTypeAsg.getAssignment().isManaged()); + etpt.setShownInEditView(propertyTypeAsg.getAssignment().isShownInEditView()); + etpt.setShowRawValue(propertyTypeAsg.getAssignment().getShowRawValue()); + + if(propertyTypeAsg.getAssignment().getScriptName() != null) { + Script scriptNew = new Script(); + scriptNew.setName(propertyTypeAsg.getAssignment().getScriptName()); + etpt.setScript(scriptNew); + } + + return etpt; + } }