diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/model/DetailedSearchFieldComboModel.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/model/DetailedSearchFieldComboModel.java index 07696d8ee868233cfbb9336ce32a4c1ba78ba6d1..6db73eb071bab4802466cb7c3c60b9361cc50973 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/model/DetailedSearchFieldComboModel.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/model/DetailedSearchFieldComboModel.java @@ -17,20 +17,31 @@ package ch.systemsx.cisd.openbis.generic.client.web.client.application.model; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DetailedSearchField; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ISearchFieldKind; /** Model of combo box used in detailed entity search. */ public class DetailedSearchFieldComboModel extends SimplifiedBaseModelData { private static final long serialVersionUID = 1L; - public DetailedSearchFieldComboModel(String code, DetailedSearchField field) + private static final String KIND = "kind"; + + public DetailedSearchFieldComboModel(String code, DetailedSearchField field, + ISearchFieldKind kind) { set(ModelDataPropertyNames.CODE, code); set(ModelDataPropertyNames.OBJECT, field); + set(KIND, kind); } public DetailedSearchField getField() { return get(ModelDataPropertyNames.OBJECT); } + + public ISearchFieldKind getKind() + { + return get(KIND); + } + } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/search/DetailedSearchCriterionWidget.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/search/DetailedSearchCriterionWidget.java index 93e1df396576546ad7018d2e63ce6d873e42681f..83216dc0f1523fc7d5723786fcb302d703792c1e 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/search/DetailedSearchCriterionWidget.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/search/DetailedSearchCriterionWidget.java @@ -36,10 +36,11 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.application.GenericCon import ch.systemsx.cisd.openbis.generic.client.web.client.application.IViewContext; import ch.systemsx.cisd.openbis.generic.client.web.client.application.model.DetailedSearchFieldComboModel; import ch.systemsx.cisd.openbis.generic.shared.basic.AttributeSearchFieldKindProvider; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.CompareType; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DetailedSearchCriterion; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DetailedSearchField; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.EntityKind; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.IAttributeSearchFieldKind; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ISearchFieldKind; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.PropertyType; /** @@ -202,43 +203,22 @@ public class DetailedSearchCriterionWidget extends HorizontalPanel */ public DetailedSearchCriterion tryGetValue() { + String selectedValue = valueField.getValue(); + DetailedSearchField selectedField = nameField.tryGetSelectedField(); + ISearchFieldKind selectedKind = nameField.tryGetSelectedKind(); - final String selectedValue = valueField.getValue(); - final DetailedSearchField selectedFieldName = nameField.tryGetSelectedField(); - - if (selectedFieldName != null && StringUtils.isBlank(selectedValue) == false) + if (selectedField != null && StringUtils.isBlank(selectedValue) == false) { - String aCode = selectedFieldName.getAttributeCode(); - - CompareType compareType; - if ("REGISTRATION_DATE_UNTIL".equals(aCode)) - { - compareType = CompareType.LESS_THAN_OR_EQUAL; - } else if ("REGISTRATION_DATE".equals(aCode)) - { - compareType = CompareType.EQUALS; - } else if ("REGISTRATION_DATE_FROM".equals(aCode)) - { - compareType = CompareType.MORE_THAN_OR_EQUAL; - } else if ("MODIFICATION_DATE_UNTIL".equals(aCode)) - { - compareType = CompareType.LESS_THAN_OR_EQUAL; - } else if ("MODIFICATION_DATE".equals(aCode)) + if (selectedKind != null && selectedKind.getCriterionFactory() != null) { - compareType = CompareType.EQUALS; - } else if ("MODIFICATION_DATE_FROM".equals(aCode)) - { - compareType = CompareType.MORE_THAN_OR_EQUAL; + return selectedKind.getCriterionFactory().createCriterion(selectedField, + selectedValue); } else { - return new DetailedSearchCriterion(selectedFieldName, selectedValue); + return new DetailedSearchCriterion(selectedField, selectedValue); } - - return new DetailedSearchCriterion(selectedFieldName, compareType, selectedValue); - } return null; - } public String tryGetDescription() @@ -266,13 +246,15 @@ public class DetailedSearchCriterionWidget extends HorizontalPanel DetailedSearchField field = criterion.getField(); String searchString = criterion.getValue(); String description = ""; + ISearchFieldKind kind = null; + switch (field.getKind()) { case ATTRIBUTE: - description = + kind = AttributeSearchFieldKindProvider.getAttributeFieldKind( - nameField.getEntityKind(), field.getAttributeCode()) - .getDescription(); + nameField.getEntityKind(), field.getAttributeCode()); + description = ((IAttributeSearchFieldKind) kind).getDescription(); break; case PROPERTY: description = field.getPropertyCode(); @@ -288,7 +270,8 @@ public class DetailedSearchCriterionWidget extends HorizontalPanel break; } - DetailedSearchFieldComboModel model = new DetailedSearchFieldComboModel(description, field); + DetailedSearchFieldComboModel model = + new DetailedSearchFieldComboModel(description, field, kind); nameField.setValue(model); valueField.setValue(searchString); } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/search/DetailedSearchFieldsSelectionWidget.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/search/DetailedSearchFieldsSelectionWidget.java index bbcf609f019fc59edaedaadafea2c29341ba507f..146bfda22aa48a4b0a07be1de5fcf84b06c4bec6 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/search/DetailedSearchFieldsSelectionWidget.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/search/DetailedSearchFieldsSelectionWidget.java @@ -18,6 +18,7 @@ package ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.search import java.util.ArrayList; import java.util.Collections; +import java.util.Iterator; import java.util.List; import com.extjs.gxt.ui.client.store.ListStore; @@ -42,6 +43,10 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DetailedSearchField; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DetailedSearchFieldKind; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.EntityKind; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.IAttributeSearchFieldKind; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ISearchFieldAvailability; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ISearchFieldKind; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Person; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.PersonRoles; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.PropertyType; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.TableModelRowWithObject; @@ -117,6 +122,12 @@ public final class DetailedSearchFieldsSelectionWidget extends return GWTUtils.tryGetSingleSelectedCode(this); } + public ISearchFieldKind tryGetSelectedKind() + { + DetailedSearchFieldComboModel model = GWTUtils.tryGetSingleSelectedModel(this); + return model != null ? model.getKind() : null; + } + // NOTE: should be removed. See the todo for the whole class. public List<PropertyType> getAvailablePropertyTypes() { @@ -146,7 +157,8 @@ public final class DetailedSearchFieldsSelectionWidget extends @Override protected void process(final TypedTableResultSet<PropertyType> result) { - List<TableModelRowWithObject<PropertyType>> rows = result.getResultSet().getList().extractOriginalObjects(); + List<TableModelRowWithObject<PropertyType>> rows = + result.getResultSet().getList().extractOriginalObjects(); propertyTypes = new ArrayList<PropertyType>(); for (TableModelRowWithObject<PropertyType> row : rows) { @@ -215,6 +227,20 @@ public final class DetailedSearchFieldsSelectionWidget extends DetailedSearchField anyField = DetailedSearchField.createAnyField(allEntityPropertyCodes); addComplexFieldComboModel(result, anyField); + Iterator<DetailedSearchFieldComboModel> iterator = result.iterator(); + while (iterator.hasNext()) + { + DetailedSearchFieldComboModel field = iterator.next(); + ISearchFieldAvailability availability = + field.getKind() != null ? field.getKind().getAvailability() : null; + + if (availability != null + && availability.isAvailable(getPerson(), getPersonRoles()) == false) + { + iterator.remove(); + } + } + return result; } @@ -241,14 +267,15 @@ public final class DetailedSearchFieldsSelectionWidget extends DetailedSearchField complexField) { assert complexField.getKind() != DetailedSearchFieldKind.ATTRIBUTE : "attribute field not allowed"; - return new DetailedSearchFieldComboModel(getDisplayName(complexField), complexField); + return new DetailedSearchFieldComboModel(getDisplayName(complexField), complexField, null); } private static DetailedSearchFieldComboModel createAttributeFieldComboModel( DetailedSearchField attributeField, IAttributeSearchFieldKind attributeFieldKind) { assert attributeField.getKind() == DetailedSearchFieldKind.ATTRIBUTE : "attribute field required"; - return new DetailedSearchFieldComboModel(getDisplayName(attributeFieldKind), attributeField); + return new DetailedSearchFieldComboModel(getDisplayName(attributeFieldKind), + attributeField, attributeFieldKind); } private List<String> addEntityPropertyTypes(final List<DetailedSearchFieldComboModel> result, @@ -284,7 +311,7 @@ public final class DetailedSearchFieldsSelectionWidget extends String prefix = getDisplayName(searchField); String property = PropertyTypeRenderer.getDisplayName(propertyType, types); String code = prefix + " \'" + property + "\'"; - return new DetailedSearchFieldComboModel(code, searchField); + return new DetailedSearchFieldComboModel(code, searchField, null); } private static String getDisplayName(DetailedSearchField complexField) @@ -316,4 +343,14 @@ public final class DetailedSearchFieldsSelectionWidget extends { return DatabaseModificationKind.any(ObjectKind.PROPERTY_TYPE); } + + private Person getPerson() + { + return viewContext.getModel().getSessionContext().getUser().getUserPersonObject(); + } + + private PersonRoles getPersonRoles() + { + return viewContext.getModel().getSessionContext().getUser().getUserPersonRoles(); + } } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/util/GWTUtils.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/util/GWTUtils.java index 0aef3401bad14aaccaed0dc5345f6f1426d19d2f..27177ade132160a1add2cd55a3bfbb61a542a271 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/util/GWTUtils.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/util/GWTUtils.java @@ -347,8 +347,7 @@ public final class GWTUtils * * @returns <code>null</code> if nothing is selected. */ - private final static <T extends ModelData> T tryGetSingleSelectedModel( - final ComboBox<T> comboBox) + public final static <T extends ModelData> T tryGetSingleSelectedModel(final ComboBox<T> comboBox) { assert comboBox != null : "Unspecified combo box."; final List<T> selection = comboBox.getSelection(); @@ -362,20 +361,31 @@ public final class GWTUtils } /** - * Tries to return the selected object code (saved as {@link ModelDataPropertyNames#CODE} in the - * model) from the given {@link ComboBox}. + * Tries to return the selected object property from the given {@link ComboBox}. * * @returns <code>null</code> if nothing is selected. */ - public final static <T extends ModelData, O> String tryGetSingleSelectedCode( - final ComboBox<T> comboBox) + public final static <T extends ModelData, O> O tryGetSingleSelectedProperty( + final ComboBox<T> comboBox, String propertyName) { T selectedModel = GWTUtils.tryGetSingleSelectedModel(comboBox); if (selectedModel == null) { return null; } - return selectedModel.get(ModelDataPropertyNames.CODE); + return selectedModel.get(propertyName); + } + + /** + * Tries to return the selected object code (saved as {@link ModelDataPropertyNames#CODE} in the + * model) from the given {@link ComboBox}. + * + * @returns <code>null</code> if nothing is selected. + */ + public final static <T extends ModelData> String tryGetSingleSelectedCode( + final ComboBox<T> comboBox) + { + return tryGetSingleSelectedProperty(comboBox, ModelDataPropertyNames.CODE); } /** @@ -384,11 +394,9 @@ public final class GWTUtils * * @returns <code>null</code> if nothing is selected. */ - @SuppressWarnings("unchecked") public final static <T extends ModelData, O> O tryGetSingleSelected(final ComboBox<T> comboBox) { - final T selectedModel = tryGetSingleSelectedModel(comboBox); - return (O) (selectedModel != null ? selectedModel.get(ModelDataPropertyNames.OBJECT) : null); + return tryGetSingleSelectedProperty(comboBox, ModelDataPropertyNames.OBJECT); } /** Returns base URL to the index page of the application. */ diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/dto/User.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/dto/User.java index 7110c697c5d496ef04cfca4536423093f67d16cb..9e709b7b8e0cf79ea9e15427b50fedbf8b4d394d 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/dto/User.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/dto/User.java @@ -19,6 +19,7 @@ package ch.systemsx.cisd.openbis.generic.client.web.client.dto; import com.google.gwt.user.client.rpc.IsSerializable; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Person; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.PersonRoles; /** * User information to be shown in Web client. @@ -35,6 +36,8 @@ public final class User implements IsSerializable private Person userPersonObject; + private PersonRoles userPersonRoles; + public User() { } @@ -88,4 +91,15 @@ public final class User implements IsSerializable { this.userPersonObject = userPersonObject; } + + public PersonRoles getUserPersonRoles() + { + return userPersonRoles; + } + + public void setUserPersonRoles(PersonRoles userPersonRoles) + { + this.userPersonRoles = userPersonRoles; + } + } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/AbstractClientService.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/AbstractClientService.java index 604a30df49f12113734eba2441021440109874a4..dce8d743822c6731e583226847b3879ad6afd729 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/AbstractClientService.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/AbstractClientService.java @@ -316,6 +316,7 @@ public abstract class AbstractClientService implements IClientService, user.setHomeGroupCode(session.tryGetHomeGroupCode()); user.setUserEmail(session.getUserEmail()); user.setUserPersonObject(session.getUserPersonObject()); + user.setUserPersonRoles(session.getUserPersonRoles()); sessionContext.setUser(user); sessionContext.setAnonymous(session.isAnonymous()); diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/resultset/AbstractExternalDataProvider.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/resultset/AbstractExternalDataProvider.java index d2953c0945db0cb8d96282740556812aaf92284e..ef411b3d1b9aacefd2f44b89db6f74a78e1f2714 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/resultset/AbstractExternalDataProvider.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/resultset/AbstractExternalDataProvider.java @@ -191,14 +191,15 @@ public abstract class AbstractExternalDataProvider extends FileFormatType fileFormatType = realDataSet.getFileFormatType(); builder.column(FILE_FORMAT_TYPE).addString( fileFormatType == null ? "" : fileFormatType.getCode()); + builder.column(STORAGE_CONFIRMATION).addString( + SimpleYesNoRenderer.render(dataSet.isStorageConfirmation())); } builder.column(PRODUCTION_DATE).addDate(dataSet.getProductionDate()); builder.column(DATA_PRODUCER_CODE).addString(dataSet.getDataProducerCode()); builder.column(DATA_STORE_CODE).addString(dataSet.getDataStore().getCode()); builder.column(PERM_ID).addString(dataSet.getPermId()); builder.column(SHOW_DETAILS_LINK).addString(dataSet.getPermlink()); - builder.column(STORAGE_CONFIRMATION).addString( - SimpleYesNoRenderer.render(dataSet.isStorageConfirmation())); + IColumnGroup columnGroup = builder.columnGroup(PROPERTIES_PREFIX); DataSetType dataSetType = dataSet.getDataSetType(); if (dataSetType != null) diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/AbstractServer.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/AbstractServer.java index 431a947297f38d8fe2d6e394c526cdd669d18ccb..6e7960d05b2cec2cf608b74521bd9707f47c939c 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/AbstractServer.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/AbstractServer.java @@ -89,6 +89,7 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.SimpleSession; import ch.systemsx.cisd.openbis.generic.shared.dto.SpacePE; import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.SpaceIdentifier; import ch.systemsx.cisd.openbis.generic.shared.translator.GridCustomExpressionTranslator.GridCustomColumnTranslator; +import ch.systemsx.cisd.openbis.generic.shared.translator.PersonRolesTranslator; import ch.systemsx.cisd.openbis.generic.shared.translator.PersonTranslator; import ch.systemsx.cisd.openbis.generic.shared.util.HibernateUtils; import ch.systemsx.cisd.openbis.generic.shared.util.ServerUtils; @@ -661,6 +662,8 @@ public abstract class AbstractServer<T> extends AbstractServiceWithLogger<T> imp result.setUserEmail(session.getUserEmail()); result.setAnonymous(session.isAnonymous()); result.setUserPersonObject(PersonTranslator.translate(person)); + result.setUserPersonRoles(PersonRolesTranslator.translate(person.getAllPersonRoles())); + return result; } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/search/detailed/IndexFieldNameHelper.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/search/detailed/IndexFieldNameHelper.java index 68a86e208c551bd308096daff5193710bc68124d..edd31c2ff48224e58512ca8a2a41d9b56777320e 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/search/detailed/IndexFieldNameHelper.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/search/detailed/IndexFieldNameHelper.java @@ -131,6 +131,8 @@ class IndexFieldNameHelper return SearchFieldConstants.PREFIX_ENTITY_TYPE + CODE; case FILE_TYPE: return SearchFieldConstants.PREFIX_FILE_FORMAT_TYPE + CODE; + case STORAGE_CONFIRMATION: + return SearchFieldConstants.STORAGE_CONFIRMATION; case REGISTRATION_DATE: case REGISTRATION_DATE_FROM: case REGISTRATION_DATE_UNTIL: diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/DataSetAttributeSearchFieldKind.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/DataSetAttributeSearchFieldKind.java index c354c31e4da163984f5c3cd6b3f9b2d0f1bcf7ba..6e47c5b543eb0cf31e4eb5bf77e86555f07b2059 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/DataSetAttributeSearchFieldKind.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/DataSetAttributeSearchFieldKind.java @@ -18,6 +18,7 @@ package ch.systemsx.cisd.openbis.generic.shared.basic.dto; import java.io.Serializable; + /** * Kinds of fields connected with Data Set attributes that can be used in detailed text queries. * @@ -31,27 +32,48 @@ public enum DataSetAttributeSearchFieldKind implements Serializable, IAttributeS FILE_TYPE("File Type"), - REGISTRATION_DATE(CommonAttributeSearchFieldKindDecsriptions.REGISTRATION_DATE_DESCRIPTION), + STORAGE_CONFIRMATION("Storage confirmed", new SearchFieldAvailableForAdmins(), + new SearchFieldBooleanCriterionFactory()), + + REGISTRATION_DATE(CommonAttributeSearchFieldKindDecsriptions.REGISTRATION_DATE_DESCRIPTION, + null, new SearchFieldDateCriterionFactory()), - MODIFICATION_DATE(CommonAttributeSearchFieldKindDecsriptions.MODIFICATION_DATE_DESCRIPTION), + MODIFICATION_DATE(CommonAttributeSearchFieldKindDecsriptions.MODIFICATION_DATE_DESCRIPTION, + null, new SearchFieldDateCriterionFactory()), REGISTRATION_DATE_FROM( - CommonAttributeSearchFieldKindDecsriptions.REGISTRATION_DATE_FROM_DESCRIPTION), + CommonAttributeSearchFieldKindDecsriptions.REGISTRATION_DATE_FROM_DESCRIPTION, null, + new SearchFieldDateCriterionFactory()), MODIFICATION_DATE_FROM( - CommonAttributeSearchFieldKindDecsriptions.MODIFICATION_DATE_FROM_DESCRIPTION), + CommonAttributeSearchFieldKindDecsriptions.MODIFICATION_DATE_FROM_DESCRIPTION, null, + new SearchFieldDateCriterionFactory()), REGISTRATION_DATE_UNTIL( - CommonAttributeSearchFieldKindDecsriptions.REGISTRATION_DATE_UNTIL_DESCRIPTION), + CommonAttributeSearchFieldKindDecsriptions.REGISTRATION_DATE_UNTIL_DESCRIPTION, null, + new SearchFieldDateCriterionFactory()), MODIFICATION_DATE_UNTIL( - CommonAttributeSearchFieldKindDecsriptions.MODIFICATION_DATE_UNTIL_DESCRIPTION); + CommonAttributeSearchFieldKindDecsriptions.MODIFICATION_DATE_UNTIL_DESCRIPTION, null, + new SearchFieldDateCriterionFactory()); private final String description; + private final ISearchFieldAvailability availability; + + private final ISearchFieldCriterionFactory criterionFactory; + private DataSetAttributeSearchFieldKind(String description) + { + this(description, null, null); + } + + private DataSetAttributeSearchFieldKind(String description, + ISearchFieldAvailability availability, ISearchFieldCriterionFactory criterionFactory) { this.description = description; + this.availability = availability; + this.criterionFactory = criterionFactory; } @Override @@ -66,4 +88,16 @@ public enum DataSetAttributeSearchFieldKind implements Serializable, IAttributeS return name(); } + @Override + public ISearchFieldAvailability getAvailability() + { + return availability; + } + + @Override + public ISearchFieldCriterionFactory getCriterionFactory() + { + return criterionFactory; + } + } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/ExperimentAttributeSearchFieldKind.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/ExperimentAttributeSearchFieldKind.java index ad6003449b7cee2607c7e544ad12dff2a3845c76..8350647a700e06a79a7c69fb1b9559ca985e6030 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/ExperimentAttributeSearchFieldKind.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/ExperimentAttributeSearchFieldKind.java @@ -18,6 +18,7 @@ package ch.systemsx.cisd.openbis.generic.shared.basic.dto; import java.io.Serializable; + /** * Kinds of fields connected with Experiment attributes that can be used in detailed text queries. * @@ -33,27 +34,45 @@ public enum ExperimentAttributeSearchFieldKind implements Serializable, IAttribu PROJECT_SPACE("Space"), - REGISTRATION_DATE(CommonAttributeSearchFieldKindDecsriptions.REGISTRATION_DATE_DESCRIPTION), + REGISTRATION_DATE(CommonAttributeSearchFieldKindDecsriptions.REGISTRATION_DATE_DESCRIPTION, + null, new SearchFieldDateCriterionFactory()), - MODIFICATION_DATE(CommonAttributeSearchFieldKindDecsriptions.MODIFICATION_DATE_DESCRIPTION), + MODIFICATION_DATE(CommonAttributeSearchFieldKindDecsriptions.MODIFICATION_DATE_DESCRIPTION, + null, new SearchFieldDateCriterionFactory()), REGISTRATION_DATE_FROM( - CommonAttributeSearchFieldKindDecsriptions.REGISTRATION_DATE_FROM_DESCRIPTION), + CommonAttributeSearchFieldKindDecsriptions.REGISTRATION_DATE_FROM_DESCRIPTION, null, + new SearchFieldDateCriterionFactory()), MODIFICATION_DATE_FROM( - CommonAttributeSearchFieldKindDecsriptions.MODIFICATION_DATE_FROM_DESCRIPTION), + CommonAttributeSearchFieldKindDecsriptions.MODIFICATION_DATE_FROM_DESCRIPTION, null, + new SearchFieldDateCriterionFactory()), REGISTRATION_DATE_UNTIL( - CommonAttributeSearchFieldKindDecsriptions.REGISTRATION_DATE_UNTIL_DESCRIPTION), + CommonAttributeSearchFieldKindDecsriptions.REGISTRATION_DATE_UNTIL_DESCRIPTION, null, + new SearchFieldDateCriterionFactory()), MODIFICATION_DATE_UNTIL( - CommonAttributeSearchFieldKindDecsriptions.MODIFICATION_DATE_UNTIL_DESCRIPTION); + CommonAttributeSearchFieldKindDecsriptions.MODIFICATION_DATE_UNTIL_DESCRIPTION, null, + new SearchFieldDateCriterionFactory()); private final String description; + private final ISearchFieldAvailability availability; + + private final ISearchFieldCriterionFactory criterionFactory; + private ExperimentAttributeSearchFieldKind(String description) + { + this(description, null, null); + } + + private ExperimentAttributeSearchFieldKind(String description, + ISearchFieldAvailability availability, ISearchFieldCriterionFactory criterionFactory) { this.description = description; + this.availability = availability; + this.criterionFactory = criterionFactory; } @Override @@ -68,4 +87,16 @@ public enum ExperimentAttributeSearchFieldKind implements Serializable, IAttribu return name(); } + @Override + public ISearchFieldAvailability getAvailability() + { + return availability; + } + + @Override + public ISearchFieldCriterionFactory getCriterionFactory() + { + return criterionFactory; + } + } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/IAttributeSearchFieldKind.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/IAttributeSearchFieldKind.java index 8ba9da25dd3da7a87d8dcba27d5563c865a54240..c91f63c8e3c215b2a7ead37a0ccd751ac9ca2a97 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/IAttributeSearchFieldKind.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/IAttributeSearchFieldKind.java @@ -21,9 +21,10 @@ package ch.systemsx.cisd.openbis.generic.shared.basic.dto; * * @author Piotr Buczek */ -public interface IAttributeSearchFieldKind +public interface IAttributeSearchFieldKind extends ISearchFieldKind { String getCode(); String getDescription(); + } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/ISearchFieldAvailability.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/ISearchFieldAvailability.java new file mode 100644 index 0000000000000000000000000000000000000000..082e444482bc4633fd05573ad0f2a0ae05a2c0fd --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/ISearchFieldAvailability.java @@ -0,0 +1,27 @@ +/* + * Copyright 2012 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.generic.shared.basic.dto; + +/** + * @author pkupczyk + */ +public interface ISearchFieldAvailability +{ + + public boolean isAvailable(Person person, PersonRoles personRoles); + +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/ISearchFieldCriterionFactory.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/ISearchFieldCriterionFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..fc1a08a28270d135eed99400d12e7d6c976f0823 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/ISearchFieldCriterionFactory.java @@ -0,0 +1,28 @@ +/* + * Copyright 2012 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.generic.shared.basic.dto; + + +/** + * @author pkupczyk + */ +public interface ISearchFieldCriterionFactory +{ + + public DetailedSearchCriterion createCriterion(DetailedSearchField field, String value); + +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/ISearchFieldKind.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/ISearchFieldKind.java new file mode 100644 index 0000000000000000000000000000000000000000..0e798ae0c813bb9b750ffd9a1fb124a165eb6443 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/ISearchFieldKind.java @@ -0,0 +1,30 @@ +/* + * Copyright 2012 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.generic.shared.basic.dto; + + +/** + * @author pkupczyk + */ +public interface ISearchFieldKind +{ + + ISearchFieldAvailability getAvailability(); + + ISearchFieldCriterionFactory getCriterionFactory(); + +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/MaterialAttributeSearchFieldKind.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/MaterialAttributeSearchFieldKind.java index b7d3e16085bf97a6230c06ebf3653286d13397b0..dee26cc905416f4580a14df8abdb7a4b314d11cf 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/MaterialAttributeSearchFieldKind.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/MaterialAttributeSearchFieldKind.java @@ -18,6 +18,7 @@ package ch.systemsx.cisd.openbis.generic.shared.basic.dto; import java.io.Serializable; + /** * Kinds of fields connected with Material attributes that can be used in detailed text queries. * @@ -29,27 +30,45 @@ public enum MaterialAttributeSearchFieldKind implements Serializable, IAttribute MATERIAL_TYPE("Material Type"), - REGISTRATION_DATE(CommonAttributeSearchFieldKindDecsriptions.REGISTRATION_DATE_DESCRIPTION), + REGISTRATION_DATE(CommonAttributeSearchFieldKindDecsriptions.REGISTRATION_DATE_DESCRIPTION, + null, new SearchFieldDateCriterionFactory()), - MODIFICATION_DATE(CommonAttributeSearchFieldKindDecsriptions.MODIFICATION_DATE_DESCRIPTION), + MODIFICATION_DATE(CommonAttributeSearchFieldKindDecsriptions.MODIFICATION_DATE_DESCRIPTION, + null, new SearchFieldDateCriterionFactory()), REGISTRATION_DATE_FROM( - CommonAttributeSearchFieldKindDecsriptions.REGISTRATION_DATE_FROM_DESCRIPTION), + CommonAttributeSearchFieldKindDecsriptions.REGISTRATION_DATE_FROM_DESCRIPTION, null, + new SearchFieldDateCriterionFactory()), MODIFICATION_DATE_FROM( - CommonAttributeSearchFieldKindDecsriptions.MODIFICATION_DATE_FROM_DESCRIPTION), + CommonAttributeSearchFieldKindDecsriptions.MODIFICATION_DATE_FROM_DESCRIPTION, null, + new SearchFieldDateCriterionFactory()), REGISTRATION_DATE_UNTIL( - CommonAttributeSearchFieldKindDecsriptions.REGISTRATION_DATE_UNTIL_DESCRIPTION), + CommonAttributeSearchFieldKindDecsriptions.REGISTRATION_DATE_UNTIL_DESCRIPTION, null, + new SearchFieldDateCriterionFactory()), MODIFICATION_DATE_UNTIL( - CommonAttributeSearchFieldKindDecsriptions.MODIFICATION_DATE_UNTIL_DESCRIPTION); + CommonAttributeSearchFieldKindDecsriptions.MODIFICATION_DATE_UNTIL_DESCRIPTION, null, + new SearchFieldDateCriterionFactory()); private final String description; + private final ISearchFieldAvailability availability; + + private final ISearchFieldCriterionFactory criterionFactory; + private MaterialAttributeSearchFieldKind(String description) + { + this(description, null, null); + } + + private MaterialAttributeSearchFieldKind(String description, + ISearchFieldAvailability availability, ISearchFieldCriterionFactory criterionFactory) { this.description = description; + this.availability = availability; + this.criterionFactory = criterionFactory; } @Override @@ -64,4 +83,16 @@ public enum MaterialAttributeSearchFieldKind implements Serializable, IAttribute return name(); } + @Override + public ISearchFieldAvailability getAvailability() + { + return availability; + } + + @Override + public ISearchFieldCriterionFactory getCriterionFactory() + { + return criterionFactory; + } + } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/PersonRole.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/PersonRole.java new file mode 100644 index 0000000000000000000000000000000000000000..0e89211dd43c874e34c96cd6021e2218d210d1cd --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/PersonRole.java @@ -0,0 +1,75 @@ +/* + * Copyright 2012 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.generic.shared.basic.dto; + +import java.io.Serializable; + +/** + * @author pkupczyk + */ +public class PersonRole implements Serializable +{ + + private static final long serialVersionUID = ServiceVersionHolder.VERSION; + + private RoleWithHierarchy role; + + private DatabaseInstance databaseInstance; + + private Space space; + + // GWT + @SuppressWarnings("unused") + private PersonRole() + { + } + + public PersonRole(RoleWithHierarchy role, DatabaseInstance databaseInstance, Space space) + { + if (role == null) + { + throw new IllegalArgumentException("Role cannot be null"); + } + if (role.isInstanceLevel() && databaseInstance == null) + { + throw new IllegalArgumentException("Database instance cannot be null for instance role"); + } + if (role.isSpaceLevel() && space == null) + { + throw new IllegalArgumentException("Space cannot be null for space role"); + } + this.role = role; + this.databaseInstance = databaseInstance; + this.space = space; + } + + public RoleWithHierarchy getRole() + { + return role; + } + + public DatabaseInstance getDatabaseInstance() + { + return databaseInstance; + } + + public Space getSpace() + { + return space; + } + +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/PersonRoles.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/PersonRoles.java new file mode 100644 index 0000000000000000000000000000000000000000..96c826ff4d951fdc9bcc5f3a1f89a3b3b5e9041f --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/PersonRoles.java @@ -0,0 +1,60 @@ +/* + * Copyright 2012 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.generic.shared.basic.dto; + +import java.io.Serializable; +import java.util.List; + +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.RoleWithHierarchy.RoleCode; + +/** + * @author pkupczyk + */ +public class PersonRoles implements Serializable +{ + + private static final long serialVersionUID = ServiceVersionHolder.VERSION; + + private List<PersonRole> personRoles; + + // GWT + @SuppressWarnings("unused") + private PersonRoles() + { + } + + public PersonRoles(List<PersonRole> personRoles) + { + if (personRoles == null) + { + throw new IllegalArgumentException("Roles cannot be null"); + } + this.personRoles = personRoles; + } + + public boolean isAdmin() + { + for (PersonRole personRole : personRoles) + { + if (RoleCode.ADMIN.equals(personRole.getRole().getRoleCode())) + { + return true; + } + } + return false; + } +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/SampleAttributeSearchFieldKind.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/SampleAttributeSearchFieldKind.java index c087b28fd0d352cf5f9aac209fdfaa51550e03de..150f185d21bd57ff22f8228d82b709d25902fe9c 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/SampleAttributeSearchFieldKind.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/SampleAttributeSearchFieldKind.java @@ -18,6 +18,7 @@ package ch.systemsx.cisd.openbis.generic.shared.basic.dto; import java.io.Serializable; + /** * Kinds of fields connected with Sample attributes that can be used in detailed text queries. * @@ -31,27 +32,45 @@ public enum SampleAttributeSearchFieldKind implements Serializable, IAttributeSe SPACE("Space"), - REGISTRATION_DATE(CommonAttributeSearchFieldKindDecsriptions.REGISTRATION_DATE_DESCRIPTION), + REGISTRATION_DATE(CommonAttributeSearchFieldKindDecsriptions.REGISTRATION_DATE_DESCRIPTION, + null, new SearchFieldDateCriterionFactory()), - MODIFICATION_DATE(CommonAttributeSearchFieldKindDecsriptions.MODIFICATION_DATE_DESCRIPTION), + MODIFICATION_DATE(CommonAttributeSearchFieldKindDecsriptions.MODIFICATION_DATE_DESCRIPTION, + null, new SearchFieldDateCriterionFactory()), REGISTRATION_DATE_FROM( - CommonAttributeSearchFieldKindDecsriptions.REGISTRATION_DATE_FROM_DESCRIPTION), + CommonAttributeSearchFieldKindDecsriptions.REGISTRATION_DATE_FROM_DESCRIPTION, null, + new SearchFieldDateCriterionFactory()), MODIFICATION_DATE_FROM( - CommonAttributeSearchFieldKindDecsriptions.MODIFICATION_DATE_FROM_DESCRIPTION), + CommonAttributeSearchFieldKindDecsriptions.MODIFICATION_DATE_FROM_DESCRIPTION, null, + new SearchFieldDateCriterionFactory()), REGISTRATION_DATE_UNTIL( - CommonAttributeSearchFieldKindDecsriptions.REGISTRATION_DATE_UNTIL_DESCRIPTION), + CommonAttributeSearchFieldKindDecsriptions.REGISTRATION_DATE_UNTIL_DESCRIPTION, null, + new SearchFieldDateCriterionFactory()), MODIFICATION_DATE_UNTIL( - CommonAttributeSearchFieldKindDecsriptions.MODIFICATION_DATE_UNTIL_DESCRIPTION); + CommonAttributeSearchFieldKindDecsriptions.MODIFICATION_DATE_UNTIL_DESCRIPTION, null, + new SearchFieldDateCriterionFactory()); private final String description; + private final ISearchFieldAvailability availability; + + private final ISearchFieldCriterionFactory criterionFactory; + private SampleAttributeSearchFieldKind(String description) + { + this(description, null, null); + } + + private SampleAttributeSearchFieldKind(String description, + ISearchFieldAvailability availability, ISearchFieldCriterionFactory criterionFactory) { this.description = description; + this.availability = availability; + this.criterionFactory = criterionFactory; } @Override @@ -66,4 +85,16 @@ public enum SampleAttributeSearchFieldKind implements Serializable, IAttributeSe return name(); } + @Override + public ISearchFieldAvailability getAvailability() + { + return availability; + } + + @Override + public ISearchFieldCriterionFactory getCriterionFactory() + { + return criterionFactory; + } + } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/SearchFieldAvailableForAdmins.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/SearchFieldAvailableForAdmins.java new file mode 100644 index 0000000000000000000000000000000000000000..137458b6b8bf84bc650f71a06388990c6812cd38 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/SearchFieldAvailableForAdmins.java @@ -0,0 +1,31 @@ +/* + * Copyright 2012 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.generic.shared.basic.dto; + +/** + * @author pkupczyk + */ +public class SearchFieldAvailableForAdmins implements ISearchFieldAvailability +{ + + @Override + public boolean isAvailable(Person person, PersonRoles personRoles) + { + return personRoles.isAdmin(); + } + +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/SearchFieldBooleanCriterionFactory.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/SearchFieldBooleanCriterionFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..a41690598166368f630f6e4882918ceebcef5211 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/SearchFieldBooleanCriterionFactory.java @@ -0,0 +1,41 @@ +/* + * Copyright 2012 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.generic.shared.basic.dto; + + +/** + * @author pkupczyk + */ +public class SearchFieldBooleanCriterionFactory implements ISearchFieldCriterionFactory +{ + + @Override + public DetailedSearchCriterion createCriterion(DetailedSearchField field, String value) + { + if ("TRUE".equalsIgnoreCase(value) || "YES".equalsIgnoreCase(value)) + { + return new DetailedSearchCriterion(field, "true"); + } else if ("FALSE".equalsIgnoreCase(value) || "NO".equalsIgnoreCase(value)) + { + return new DetailedSearchCriterion(field, "false"); + } else + { + return null; + } + } + +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/SearchFieldDateCriterionFactory.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/SearchFieldDateCriterionFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..a02493ee12ae3239a78f5a39f4601bacac745b9f --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/SearchFieldDateCriterionFactory.java @@ -0,0 +1,58 @@ +/* + * Copyright 2012 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.generic.shared.basic.dto; + + +/** + * @author pkupczyk + */ +public class SearchFieldDateCriterionFactory implements ISearchFieldCriterionFactory +{ + + @Override + public DetailedSearchCriterion createCriterion(DetailedSearchField field, String value) + { + String code = field.getAttributeCode(); + CompareType compareType; + + if ("REGISTRATION_DATE_UNTIL".equals(code)) + { + compareType = CompareType.LESS_THAN_OR_EQUAL; + } else if ("REGISTRATION_DATE".equals(code)) + { + compareType = CompareType.EQUALS; + } else if ("REGISTRATION_DATE_FROM".equals(code)) + { + compareType = CompareType.MORE_THAN_OR_EQUAL; + } else if ("MODIFICATION_DATE_UNTIL".equals(code)) + { + compareType = CompareType.LESS_THAN_OR_EQUAL; + } else if ("MODIFICATION_DATE".equals(code)) + { + compareType = CompareType.EQUALS; + } else if ("MODIFICATION_DATE_FROM".equals(code)) + { + compareType = CompareType.MORE_THAN_OR_EQUAL; + } else + { + throw new IllegalArgumentException("Unknown date search field: " + code); + } + + return new DetailedSearchCriterion(field, compareType, value); + } + +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/ExternalDataPE.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/ExternalDataPE.java index c78cb671510f5efedce023f81f8297c62041a562..8b12f78950ce0d529eed78eb575514553d3c15c5 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/ExternalDataPE.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/ExternalDataPE.java @@ -29,8 +29,11 @@ import javax.persistence.Transient; import javax.persistence.UniqueConstraint; import javax.validation.constraints.NotNull; +import org.hibernate.search.annotations.Field; +import org.hibernate.search.annotations.Index; import org.hibernate.search.annotations.Indexed; import org.hibernate.search.annotations.IndexedEmbedded; +import org.hibernate.search.annotations.Store; import org.hibernate.validator.constraints.Length; import ch.systemsx.cisd.common.types.BooleanOrUnknown; @@ -229,6 +232,7 @@ public final class ExternalDataPE extends DataPE } @Column(name = ColumnNames.STORAGE_CONFIRMATION) + @Field(name = SearchFieldConstants.STORAGE_CONFIRMATION, index = Index.UN_TOKENIZED, store = Store.YES) public boolean isStorageConfirmation() { return storageConfirmation; diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/SessionContextDTO.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/SessionContextDTO.java index c523ba6d6887e1032e8164fae65abb4fb84ea47e..ee2e8d3e70bfc36ff5a46e518c8f8b11a3be7d85 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/SessionContextDTO.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/SessionContextDTO.java @@ -21,6 +21,7 @@ import java.io.Serializable; import ch.systemsx.cisd.openbis.generic.shared.IServer; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DisplaySettings; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Person; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.PersonRoles; /** * An extract from the Session object, used internally on the server side. @@ -47,6 +48,8 @@ public class SessionContextDTO implements Serializable private Person userPersonObject; + private PersonRoles userPersonRoles; + public void setSessionToken(String sessionToken) { this.sessionToken = sessionToken; @@ -126,4 +129,14 @@ public class SessionContextDTO implements Serializable { return userPersonObject; } + + public void setUserPersonRoles(PersonRoles userPersonRoles) + { + this.userPersonRoles = userPersonRoles; + } + + public PersonRoles getUserPersonRoles() + { + return userPersonRoles; + } } \ No newline at end of file diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/hibernate/SearchFieldConstants.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/hibernate/SearchFieldConstants.java index 2dd6f9d34847500323c2449efa044ba01d105ce1..22f42bd4fc2eb0a8db284e2a38eef5e55052ad80 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/hibernate/SearchFieldConstants.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/hibernate/SearchFieldConstants.java @@ -89,6 +89,8 @@ public final class SearchFieldConstants public static final String FILE_DESCRIPTION = "description"; + public static final String STORAGE_CONFIRMATION = "storage_confirmed"; + public static final String REGISTRATION_DATE = "registration_date"; public static final String MODIFICATION_DATE = "modification_date"; diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/translator/PersonRolesTranslator.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/translator/PersonRolesTranslator.java new file mode 100644 index 0000000000000000000000000000000000000000..65a08e294ef90ad67476a1a9ab935e4b3575dc39 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/translator/PersonRolesTranslator.java @@ -0,0 +1,87 @@ +/* + * Copyright 2012 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.generic.shared.translator; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DatabaseInstance; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.PersonRole; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.PersonRoles; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.RoleWithHierarchy; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.RoleWithHierarchy.RoleLevel; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Space; +import ch.systemsx.cisd.openbis.generic.shared.dto.RoleAssignmentPE; + +/** + * @author pkupczyk + */ +public class PersonRolesTranslator +{ + + private PersonRolesTranslator() + { + // Can not be instantiated. + } + + public final static PersonRoles translate(final Collection<RoleAssignmentPE> roleAssignments) + { + final List<PersonRole> personRoles = new ArrayList<PersonRole>(); + + if (roleAssignments != null) + { + for (final RoleAssignmentPE roleAssignment : roleAssignments) + { + PersonRole personRole = translate(roleAssignment); + if (personRole != null) + { + personRoles.add(personRole); + } + } + } + + return new PersonRoles(personRoles); + } + + private final static PersonRole translate(final RoleAssignmentPE roleAssignment) + { + if (roleAssignment == null) + { + return null; + } + + RoleWithHierarchy role; + + if (roleAssignment.getDatabaseInstance() != null) + { + role = RoleWithHierarchy.valueOf(RoleLevel.INSTANCE, roleAssignment.getRole()); + } else if (roleAssignment.getSpace() != null) + { + role = RoleWithHierarchy.valueOf(RoleLevel.SPACE, roleAssignment.getRole()); + } else + { + throw new IllegalArgumentException("Database instance and space cannot be both null"); + } + + DatabaseInstance databaseInstance = + DatabaseInstanceTranslator.translate(roleAssignment.getDatabaseInstance()); + Space space = SpaceTranslator.translate(roleAssignment.getSpace()); + + return new PersonRole(role, databaseInstance, space); + } +}