diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/IGenericClientService.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/IGenericClientService.java index 61a1876d1c15be078eff25b50a3f816a4ec8b51c..f7b4bb0c25e4c8f62da1d181540330e324ae3fa8 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/IGenericClientService.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/IGenericClientService.java @@ -24,6 +24,8 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.dto.ApplicationInfo; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.Group; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.Person; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.RoleAssignment; +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.Sample; +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.SampleType; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.SessionContext; import ch.systemsx.cisd.openbis.generic.client.web.client.exception.UserFailureException; @@ -102,4 +104,14 @@ public interface IGenericClientService extends RemoteService * Deletes the role described by given role set code and person code */ public void deleteInstanceRole(String roleSetCode, String person) throws UserFailureException; + + /** + * Returns a list of sample types. + */ + public List<SampleType> listSampleTypes() throws UserFailureException; + + /** + * Returns a list of samples for given sample type. + */ + public List<Sample> listSamples(SampleType sampleType); } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/IGenericClientServiceAsync.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/IGenericClientServiceAsync.java index 7f78348bf8c485f3ce075f671e08f008a480a107..23a325ccce5850a6b0c77d038d47473b89295e9c 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/IGenericClientServiceAsync.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/IGenericClientServiceAsync.java @@ -24,6 +24,8 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.dto.ApplicationInfo; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.Group; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.Person; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.RoleAssignment; +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.Sample; +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.SampleType; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.SessionContext; /** @@ -77,4 +79,10 @@ public interface IGenericClientServiceAsync public void deleteInstanceRole(String roleSetCode, String person, AsyncCallback<Void> asyncCallback); + /** @see IGenericClientService#listSampleTypes() */ + public void listSampleTypes(AsyncCallback<List<SampleType>> asyncCallback); + + /** @see IGenericClientService#listSamples(SampleType) */ + public void listSamples(SampleType sampleType, AsyncCallback<List<Sample>> asyncCallback); + } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/Application.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/Application.java index 8be6fe14ca3b3d90b2751a8a27c27052d6b832d6..49510e81b7ada517feaf91f37fd1e333e82a82ac 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/Application.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/Application.java @@ -18,18 +18,17 @@ package ch.systemsx.cisd.openbis.generic.client.web.client.application; import com.extjs.gxt.ui.client.util.Margins; import com.extjs.gxt.ui.client.widget.LayoutContainer; -import com.extjs.gxt.ui.client.widget.TabItem; -import com.extjs.gxt.ui.client.widget.TabPanel; import com.extjs.gxt.ui.client.widget.Viewport; import com.extjs.gxt.ui.client.widget.layout.FitLayout; import com.extjs.gxt.ui.client.widget.layout.RowData; import com.extjs.gxt.ui.client.widget.layout.RowLayout; +import com.google.gwt.user.client.Window; +import com.google.gwt.user.client.ui.Widget; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.Footer; -import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.GroupsView; -import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.PersonsView; -import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.RolesView; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.TopMenu; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.amc.AMC; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.sample_browser.SampleBrowser; /** * Panel of the application. @@ -54,7 +53,7 @@ public class Application extends Viewport panels.setLayout(new RowLayout()); TopMenu north = new TopMenu(viewContext); - MainPanel center = new MainPanel(viewContext); + Widget center = chosenMainPanel(viewContext); Footer south = new Footer(viewContext); RowData northData = new RowData(1, -1, new Margins(MARGIN_SIZE)); @@ -68,34 +67,14 @@ public class Application extends Viewport add(panels); } - class MainPanel extends TabPanel + private Widget chosenMainPanel(final GenericViewContext viewContext) { - - public MainPanel(GenericViewContext viewContext) + if ("amc".equals(Window.Location.getParameter("view"))) { - - TabItem groupsTab = new TabItem(viewContext.getMessage("groupsView_heading")); - groupsTab.addStyleName("pad-text"); - GroupsView groupList = new GroupsView(viewContext); - groupList.refresh(); - groupsTab.add(groupList); - - TabItem personsTab = new TabItem(viewContext.getMessage("personsView_heading")); - personsTab.addStyleName("pad-text"); - PersonsView personList = new PersonsView(viewContext); - personList.refresh(); - personsTab.add(personList); - - TabItem rolesTab = new TabItem(viewContext.getMessage("rolesView_heading")); - rolesTab.addStyleName("pad-text"); - RolesView roleList = new RolesView(viewContext); - roleList.refresh(); - rolesTab.add(roleList); - - add(personsTab); - add(groupsTab); - add(rolesTab); - + return new AMC(viewContext); + } else + { + return new SampleBrowser(viewContext); } } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/ColumnFilter.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/ColumnFilter.java index cc9bb053d48a74aa753df4384571a68b280dfdb4..db4a02d97fdc986d1b8477457d24f220bc3a1ca7 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/ColumnFilter.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/ColumnFilter.java @@ -25,7 +25,7 @@ import com.extjs.gxt.ui.client.widget.StoreFilterField; * * @author Izabela Adamczyk */ -class ColumnFilter<T extends ModelData> extends StoreFilterField<T> +public class ColumnFilter<T extends ModelData> extends StoreFilterField<T> { private final String column; diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/PersonRenderer.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/PersonRenderer.java index 9123ff431b110d7355794e4d1311b7319247cdea..150b5a35af19984852193c27fe7effb3c7ca51b8 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/PersonRenderer.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/PersonRenderer.java @@ -16,27 +16,24 @@ package ch.systemsx.cisd.openbis.generic.client.web.client.application.ui; +import com.extjs.gxt.ui.client.data.ModelData; +import com.extjs.gxt.ui.client.store.ListStore; +import com.extjs.gxt.ui.client.widget.grid.ColumnData; +import com.extjs.gxt.ui.client.widget.grid.GridCellRenderer; + import ch.systemsx.cisd.openbis.generic.client.web.client.dto.Person; /** - * Helper creating brief {@link Person} description. - * * @author Izabela Adamczyk */ -class PersonRenderer +public class PersonRenderer implements GridCellRenderer<ModelData> { - Person person; - - public PersonRenderer(Person p) - { - person = p; - - } - @Override - public String toString() + public String render(ModelData model, String property, ColumnData config, int rowIndex, + int colIndex, ListStore<ModelData> store) { - StringBuilder sb = new StringBuilder(); + Person person = (Person) model.get(property); + StringBuilder result = new StringBuilder(); if (person != null) { String userId = person.getUserId(); @@ -46,14 +43,14 @@ class PersonRenderer { if (firstName != null) { - sb.append(firstName + " "); + result.append(firstName + " "); } - sb.append(lastName); + result.append(lastName); } else { - sb.append(userId); + result.append(userId); } } - return sb.toString(); + return result.toString(); } -} \ No newline at end of file +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/amc/AMC.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/amc/AMC.java new file mode 100644 index 0000000000000000000000000000000000000000..5e4c4e2dfd65f8d0300d241236b6347e4f677641 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/amc/AMC.java @@ -0,0 +1,53 @@ +/* + * Copyright 2008 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.client.web.client.application.ui.amc; + +import com.extjs.gxt.ui.client.widget.TabItem; +import com.extjs.gxt.ui.client.widget.TabPanel; + +import ch.systemsx.cisd.openbis.generic.client.web.client.application.GenericViewContext; + +public class AMC extends TabPanel +{ + + public AMC(GenericViewContext viewContext) + { + + TabItem groupsTab = new TabItem(viewContext.getMessage("groupsView_heading")); + groupsTab.addStyleName("pad-text"); + GroupsView groupList = new GroupsView(viewContext); + groupList.refresh(); + groupsTab.add(groupList); + + TabItem personsTab = new TabItem(viewContext.getMessage("personsView_heading")); + personsTab.addStyleName("pad-text"); + PersonsView personList = new PersonsView(viewContext); + personList.refresh(); + personsTab.add(personList); + + TabItem rolesTab = new TabItem(viewContext.getMessage("rolesView_heading")); + rolesTab.addStyleName("pad-text"); + RolesView roleList = new RolesView(viewContext); + roleList.refresh(); + rolesTab.add(roleList); + + add(personsTab); + add(groupsTab); + add(rolesTab); + + } +} \ No newline at end of file diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/AddGroupDialog.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/amc/AddGroupDialog.java similarity index 99% rename from openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/AddGroupDialog.java rename to openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/amc/AddGroupDialog.java index 72ba995b0e710fc59b03dedc58df772785e96cd6..2bc1d3901be53f70219f8db9690d4dfaa9d2fd52 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/AddGroupDialog.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/amc/AddGroupDialog.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package ch.systemsx.cisd.openbis.generic.client.web.client.application.ui; +package ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.amc; import com.extjs.gxt.ui.client.event.ComponentEvent; import com.extjs.gxt.ui.client.event.SelectionListener; @@ -52,8 +52,9 @@ public class AddGroupDialog extends Window } private static final String PREFIX = "add-group_"; - + static final String CODE_FIELD_ID = GenericConstants.ID_PREFIX + PREFIX + "code-field"; + static final String SAVE_BUTTON_ID = GenericConstants.ID_PREFIX + PREFIX + "save-button"; private final GroupsView groupList; diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/AddPersonDialog.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/amc/AddPersonDialog.java similarity index 99% rename from openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/AddPersonDialog.java rename to openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/amc/AddPersonDialog.java index 68fa42dbf87fe554b48a03e909ec53aab2b7fac6..70167ca6589ed1af3d06e7c4c7e32e0c9597b2f7 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/AddPersonDialog.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/amc/AddPersonDialog.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package ch.systemsx.cisd.openbis.generic.client.web.client.application.ui; +package ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.amc; import com.extjs.gxt.ui.client.event.ComponentEvent; import com.extjs.gxt.ui.client.event.SelectionListener; diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/AddRoleDialog.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/amc/AddRoleDialog.java similarity index 99% rename from openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/AddRoleDialog.java rename to openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/amc/AddRoleDialog.java index ca69d5d4c75ed06a104b38353669d6a7b1f0375a..4a79464c51627f1a9791528ee3f197a495b298ac 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/AddRoleDialog.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/amc/AddRoleDialog.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package ch.systemsx.cisd.openbis.generic.client.web.client.application.ui; +package ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.amc; import com.extjs.gxt.ui.client.event.ComponentEvent; import com.extjs.gxt.ui.client.event.SelectionListener; diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/GroupModel.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/amc/GroupModel.java similarity index 98% rename from openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/GroupModel.java rename to openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/amc/GroupModel.java index 0d9134a9752f3ecb2ea08426348da05d4490cf5c..6a4ad20efa41aca7451027a2d5b621efa5311a23 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/GroupModel.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/amc/GroupModel.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package ch.systemsx.cisd.openbis.generic.client.web.client.application.ui; +package ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.amc; import com.extjs.gxt.ui.client.data.BaseModelData; import com.extjs.gxt.ui.client.data.ModelData; @@ -28,6 +28,7 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.dto.Group; */ public class GroupModel extends BaseModelData { + static final String CODE = "code"; private static final long serialVersionUID = 1L; diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/GroupsView.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/amc/GroupsView.java similarity index 88% rename from openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/GroupsView.java rename to openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/amc/GroupsView.java index 14e5fea4fef7858cdca4610f4d9ea4f12e72d686..f653da1925a1e44d6c920c2b1b646811e377aac9 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/GroupsView.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/amc/GroupsView.java @@ -14,9 +14,12 @@ * limitations under the License. */ -package ch.systemsx.cisd.openbis.generic.client.web.client.application.ui; +package ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.amc; -import static ch.systemsx.cisd.openbis.generic.client.web.client.application.util.ClientConstants.*; +import static ch.systemsx.cisd.openbis.generic.client.web.client.application.util.ClientConstants.COL_DATE; +import static ch.systemsx.cisd.openbis.generic.client.web.client.application.util.ClientConstants.COL_GROUP; +import static ch.systemsx.cisd.openbis.generic.client.web.client.application.util.ClientConstants.COL_PERSON; +import static ch.systemsx.cisd.openbis.generic.client.web.client.application.util.ClientConstants.FIT_SIZE; import java.util.ArrayList; import java.util.List; @@ -31,10 +34,8 @@ import com.extjs.gxt.ui.client.widget.LayoutContainer; import com.extjs.gxt.ui.client.widget.Text; import com.extjs.gxt.ui.client.widget.button.Button; import com.extjs.gxt.ui.client.widget.grid.ColumnConfig; -import com.extjs.gxt.ui.client.widget.grid.ColumnData; import com.extjs.gxt.ui.client.widget.grid.ColumnModel; import com.extjs.gxt.ui.client.widget.grid.Grid; -import com.extjs.gxt.ui.client.widget.grid.GridCellRenderer; import com.extjs.gxt.ui.client.widget.grid.RowExpander; import com.extjs.gxt.ui.client.widget.layout.FitLayout; import com.extjs.gxt.ui.client.widget.toolbar.AdapterToolItem; @@ -46,8 +47,9 @@ import com.google.gwt.i18n.client.DateTimeFormat; import ch.systemsx.cisd.openbis.generic.client.web.client.application.AbstractAsyncCallback; import ch.systemsx.cisd.openbis.generic.client.web.client.application.GenericConstants; import ch.systemsx.cisd.openbis.generic.client.web.client.application.GenericViewContext; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.ColumnFilter; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.PersonRenderer; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.Group; -import ch.systemsx.cisd.openbis.generic.client.web.client.dto.Person; /** * {@link LayoutContainer} with groups functionality. @@ -57,10 +59,11 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.dto.Person; public class GroupsView extends LayoutContainer { private static final String PREFIX = "groups-view_"; - + static final String TABLE_ID = GenericConstants.ID_PREFIX + PREFIX + "table"; + static final String ADD_BUTTON_ID = GenericConstants.ID_PREFIX + PREFIX + "add-button"; - + final class ListGroupsCallback extends AbstractAsyncCallback<List<Group>> { private ListGroupsCallback(GenericViewContext viewContext) @@ -100,28 +103,18 @@ public class GroupsView extends LayoutContainer codeColumnConfig.setWidth(COL_GROUP); configs.add(codeColumnConfig); - GridCellRenderer<GroupModel> personRenderer = new GridCellRenderer<GroupModel>() - { - public String render(GroupModel model, String property, ColumnData config, - int rowIndex, int colIndex, ListStore<GroupModel> store) - { - Person person = (Person) model.get(property); - return new PersonRenderer(person).toString(); - } - }; - ColumnConfig leaderColumnConfig = new ColumnConfig(); leaderColumnConfig.setId("leader"); leaderColumnConfig.setHeader("Leader"); leaderColumnConfig.setWidth(COL_PERSON); - leaderColumnConfig.setRenderer(personRenderer); + leaderColumnConfig.setRenderer(new PersonRenderer()); configs.add(leaderColumnConfig); ColumnConfig registratorColumnConfig = new ColumnConfig(); registratorColumnConfig.setId("registrator"); registratorColumnConfig.setHeader("Registrator"); registratorColumnConfig.setWidth(COL_PERSON); - registratorColumnConfig.setRenderer(personRenderer); + registratorColumnConfig.setRenderer(new PersonRenderer()); configs.add(registratorColumnConfig); ColumnConfig registrationDateColumnConfig = new ColumnConfig(); diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/PersonModel.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/amc/PersonModel.java similarity index 99% rename from openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/PersonModel.java rename to openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/amc/PersonModel.java index e4e624724229c7347aa1f0c62afb0cb90bc34f26..1ec248379e815b69fd9c04b22b042414e3637a45 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/PersonModel.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/amc/PersonModel.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package ch.systemsx.cisd.openbis.generic.client.web.client.application.ui; +package ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.amc; import java.util.ArrayList; diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/PersonsView.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/amc/PersonsView.java similarity index 86% rename from openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/PersonsView.java rename to openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/amc/PersonsView.java index a83e6796f1ca0601d19e55d71e74ac4f00ca95f2..776a016f40a4ab777ecdcebdf2ff0a58237b14f1 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/PersonsView.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/amc/PersonsView.java @@ -1,3 +1,5 @@ +package ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.amc; + /* * Copyright 2008 ETH Zuerich, CISD * @@ -14,9 +16,14 @@ * limitations under the License. */ -package ch.systemsx.cisd.openbis.generic.client.web.client.application.ui; +import static ch.systemsx.cisd.openbis.generic.client.web.client.application.util.ClientConstants.COL_DATE; +import static ch.systemsx.cisd.openbis.generic.client.web.client.application.util.ClientConstants.COL_EMAIL; +import static ch.systemsx.cisd.openbis.generic.client.web.client.application.util.ClientConstants.COL_FIRST_NAME; +import static ch.systemsx.cisd.openbis.generic.client.web.client.application.util.ClientConstants.COL_LAST_NAME; +import static ch.systemsx.cisd.openbis.generic.client.web.client.application.util.ClientConstants.COL_PERSON; +import static ch.systemsx.cisd.openbis.generic.client.web.client.application.util.ClientConstants.COL_PERSON_ID; +import static ch.systemsx.cisd.openbis.generic.client.web.client.application.util.ClientConstants.FIT_SIZE; -import static ch.systemsx.cisd.openbis.generic.client.web.client.application.util.ClientConstants.*; import java.util.ArrayList; import java.util.List; @@ -29,10 +36,8 @@ import com.extjs.gxt.ui.client.widget.LayoutContainer; import com.extjs.gxt.ui.client.widget.Text; import com.extjs.gxt.ui.client.widget.button.Button; import com.extjs.gxt.ui.client.widget.grid.ColumnConfig; -import com.extjs.gxt.ui.client.widget.grid.ColumnData; import com.extjs.gxt.ui.client.widget.grid.ColumnModel; import com.extjs.gxt.ui.client.widget.grid.Grid; -import com.extjs.gxt.ui.client.widget.grid.GridCellRenderer; import com.extjs.gxt.ui.client.widget.layout.FitLayout; import com.extjs.gxt.ui.client.widget.toolbar.AdapterToolItem; import com.extjs.gxt.ui.client.widget.toolbar.LabelToolItem; @@ -43,6 +48,8 @@ import com.google.gwt.i18n.client.DateTimeFormat; import ch.systemsx.cisd.openbis.generic.client.web.client.application.AbstractAsyncCallback; import ch.systemsx.cisd.openbis.generic.client.web.client.application.GenericConstants; import ch.systemsx.cisd.openbis.generic.client.web.client.application.GenericViewContext; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.ColumnFilter; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.PersonRenderer; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.Person; /** @@ -53,7 +60,7 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.dto.Person; public class PersonsView extends LayoutContainer { private static final String PREFIX = "persons-view_"; - + static final String ADD_BUTTON_ID = GenericConstants.ID_PREFIX + PREFIX + "add-button"; private final GenericViewContext viewContext; @@ -95,21 +102,11 @@ public class PersonsView extends LayoutContainer emailNameColumnConfig.setWidth(COL_EMAIL); configs.add(emailNameColumnConfig); - GridCellRenderer<PersonModel> personRenderer = new GridCellRenderer<PersonModel>() - { - public String render(PersonModel model, String property, ColumnData config, - int rowIndex, int colIndex, ListStore<PersonModel> store) - { - Person person = (Person) model.get(property); - return new PersonRenderer(person).toString(); - } - }; - ColumnConfig registratorColumnConfig = new ColumnConfig(); registratorColumnConfig.setId("registrator"); registratorColumnConfig.setHeader("Registrator"); registratorColumnConfig.setWidth(COL_PERSON); - registratorColumnConfig.setRenderer(personRenderer); + registratorColumnConfig.setRenderer(new PersonRenderer()); configs.add(registratorColumnConfig); ColumnConfig registrationDateColumnConfig = new ColumnConfig(); diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/RoleListBox.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/amc/RoleListBox.java similarity index 99% rename from openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/RoleListBox.java rename to openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/amc/RoleListBox.java index fd845b449ff9a44cecda1a2d972f56058ecdfef8..9a0ddd43bc53d40331b1981ddd61358c576b987a 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/RoleListBox.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/amc/RoleListBox.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package ch.systemsx.cisd.openbis.generic.client.web.client.application.ui; +package ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.amc; import com.extjs.gxt.ui.client.widget.form.TextField; import com.google.gwt.user.client.ui.ChangeListener; diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/RoleModel.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/amc/RoleModel.java similarity index 98% rename from openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/RoleModel.java rename to openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/amc/RoleModel.java index 9a89a2ecf7562d9ff17f715c19d0fdeea5eb7e4a..7de31f2dfd4db343995640c396c2c28b26260dcd 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/RoleModel.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/amc/RoleModel.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package ch.systemsx.cisd.openbis.generic.client.web.client.application.ui; +package ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.amc; import com.extjs.gxt.ui.client.data.BaseModelData; import com.extjs.gxt.ui.client.data.ModelData; diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/RolesView.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/amc/RolesView.java similarity index 98% rename from openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/RolesView.java rename to openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/amc/RolesView.java index 95b5e64c863e8f01580de4a8a06de57616118b3b..c5a82d691b6704ea732bafd8165b3e43935c11b3 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/RolesView.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/amc/RolesView.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package ch.systemsx.cisd.openbis.generic.client.web.client.application.ui; +package ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.amc; import static ch.systemsx.cisd.openbis.generic.client.web.client.application.util.ClientConstants.COL_DB_INSTANCE; import static ch.systemsx.cisd.openbis.generic.client.web.client.application.util.ClientConstants.COL_GROUP; @@ -44,6 +44,7 @@ import com.extjs.gxt.ui.client.widget.toolbar.ToolBar; import ch.systemsx.cisd.openbis.generic.client.web.client.application.AbstractAsyncCallback; import ch.systemsx.cisd.openbis.generic.client.web.client.application.GenericViewContext; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.ColumnFilter; import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.StringUtils; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.RoleAssignment; diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample_browser/LeftPanel.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample_browser/LeftPanel.java new file mode 100644 index 0000000000000000000000000000000000000000..6eeb43906bc6f608bd8404827130127d300111d5 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample_browser/LeftPanel.java @@ -0,0 +1,94 @@ +/* + * Copyright 2008 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.client.web.client.application.ui.sample_browser; + +import java.util.List; + +import com.extjs.gxt.ui.client.event.ComponentEvent; +import com.extjs.gxt.ui.client.event.SelectionListener; +import com.extjs.gxt.ui.client.store.ListStore; +import com.extjs.gxt.ui.client.widget.LayoutContainer; +import com.extjs.gxt.ui.client.widget.MessageBox; +import com.extjs.gxt.ui.client.widget.button.Button; +import com.extjs.gxt.ui.client.widget.layout.FlowLayout; + +import ch.systemsx.cisd.openbis.generic.client.web.client.application.AbstractAsyncCallback; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.GenericViewContext; +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.SampleType; + +class LeftPanel extends LayoutContainer +{ + + final RightPanel rightPanel; + + private final GenericViewContext viewContext; + + public LeftPanel(GenericViewContext viewContext, RightPanel rightPanel) + { + this.viewContext = viewContext; + this.rightPanel = rightPanel; + setLayout(new FlowLayout()); + setBorders(true); + refresh(); + + } + + private void display(List<SampleType> sampleTypes) + { + removeAll(); + ListStore<SampleTypeModel> sampleTypeStore = new ListStore<SampleTypeModel>(); + for (SampleType st : sampleTypes) + { + sampleTypeStore.add(new SampleTypeModel(st)); + } + final SampleTypeSelectionWidget sampleTypeSelectionWidget = + new SampleTypeSelectionWidget(sampleTypeStore); + add(sampleTypeSelectionWidget); + add(new Button("View >>", new SelectionListener<ComponentEvent>() + { + @Override + public void componentSelected(ComponentEvent ce) + { + + final SampleType selectedType = sampleTypeSelectionWidget.tryGetSelected(); + if (selectedType != null) + { + rightPanel.refresh(selectedType); + } else + { + MessageBox.alert("Sample type not selected", + "Please choose a sample type.", null); + } + } + })); + layout(); + } + + public void refresh() + { + viewContext.getService().listSampleTypes( + new AbstractAsyncCallback<List<SampleType>>(viewContext) + { + @Override + public void process(List<SampleType> sampleTypes) + { + display(sampleTypes); + } + }); + } + +} \ No newline at end of file diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample_browser/RightPanel.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample_browser/RightPanel.java new file mode 100644 index 0000000000000000000000000000000000000000..5f523c187787fbf2ef693896e6b01e98408beab2 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample_browser/RightPanel.java @@ -0,0 +1,185 @@ +/* + * Copyright 2008 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.client.web.client.application.ui.sample_browser; + +import java.util.ArrayList; +import java.util.List; + +import com.extjs.gxt.ui.client.store.ListStore; +import com.extjs.gxt.ui.client.widget.ContentPanel; +import com.extjs.gxt.ui.client.widget.LayoutContainer; +import com.extjs.gxt.ui.client.widget.Text; +import com.extjs.gxt.ui.client.widget.grid.ColumnConfig; +import com.extjs.gxt.ui.client.widget.grid.ColumnModel; +import com.extjs.gxt.ui.client.widget.grid.Grid; +import com.extjs.gxt.ui.client.widget.layout.FitLayout; +import com.google.gwt.i18n.client.DateTimeFormat; + +import ch.systemsx.cisd.openbis.generic.client.web.client.application.AbstractAsyncCallback; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.GenericViewContext; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.PersonRenderer; +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.Sample; +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.SampleType; + +class RightPanel extends LayoutContainer +{ + + private final GenericViewContext viewContext; + + public RightPanel(GenericViewContext viewContext) + { + this.viewContext = viewContext; + setLayout(new FitLayout()); + setBorders(true); + } + + private void display(List<Sample> samples, SampleType sampleType) + { + ListStore<SampleModel> sampleStore = new ListStore<SampleModel>(); + for (Sample s : samples) + { + sampleStore.add(new SampleModel(s)); + } + final ContentPanel cp = new ContentPanel(); + cp.setHeading(sampleType.getCode() + " samples"); + cp.setLayout(new FitLayout()); + + Grid<SampleModel> grid = new Grid<SampleModel>(sampleStore, createColumnModel(sampleType)); + cp.add(grid); + + removeAll(); + add(cp); + layout(); + + } + + public void refresh(final SampleType sampleType) + { + removeAll(); + add(new Text("data loading...")); + viewContext.getService().listSamples(sampleType, + new AbstractAsyncCallback<List<Sample>>(viewContext) + { + @Override + public void process(List<Sample> samples) + { + display(samples, sampleType); + } + + }); + } + + ColumnModel createColumnModel(SampleType type) + { + List<ColumnConfig> configs = new ArrayList<ColumnConfig>(); + configs.add(createCodeColumn()); + configs.add(createIdentifierColumn()); + configs.add(createAssignedToIdentifierColumn()); + configs.add(createRegistratorColumn()); + configs.add(createRegistionDateColumn()); + addGeneratedFromParentColumns(configs, 1, type.getGeneratedFromHierarchyDepth()); + addContainerParentColumns(configs, 1, type.getPartOfHierarchyDepth()); + return new ColumnModel(configs); + } + + private ColumnConfig createIdentifierColumn() + { + ColumnConfig columnConfig = new ColumnConfig(); + columnConfig.setId(SampleModel.SAMPLE_IDENTIFIER); + columnConfig.setHeader("Identifier"); + columnConfig.setHidden(true); + columnConfig.setWidth(150); + return columnConfig; + } + + private ColumnConfig createCodeColumn() + { + ColumnConfig columnConfig = new ColumnConfig(); + columnConfig.setId(SampleModel.SAMPLE_CODE); + columnConfig.setHeader("Code"); + columnConfig.setWidth(100); + return columnConfig; + } + + private ColumnConfig createAssignedToIdentifierColumn() + { + ColumnConfig columnConfig = new ColumnConfig(); + columnConfig.setId(SampleModel.ATTACHED_TO_IDENTIFIER); + columnConfig.setHeader("Attached to"); + columnConfig.setWidth(100); + return columnConfig; + } + + private ColumnConfig createRegistratorColumn() + { + ColumnConfig columnConfig = new ColumnConfig(); + columnConfig.setId(SampleModel.REGISTRATOR); + columnConfig.setHeader("Registrator"); + columnConfig.setWidth(100); + columnConfig.setRenderer(new PersonRenderer()); + columnConfig.setHidden(true); + return columnConfig; + } + + private ColumnConfig createRegistionDateColumn() + { + ColumnConfig columnConfig = new ColumnConfig(); + columnConfig.setId(SampleModel.REGISTRATION_DATE); + columnConfig.setHeader("Registration Date"); + columnConfig.setWidth(100); + columnConfig.setDateTimeFormat(DateTimeFormat.getShortDateFormat()); + columnConfig.setHidden(true); + return columnConfig; + } + + private void addGeneratedFromParentColumns(List<ColumnConfig> configs, int dep, int maxDep) + { + if (dep <= maxDep) + { + configs.add(createGeneratedFromParentColumn(dep)); + addGeneratedFromParentColumns(configs, dep + 1, maxDep); + } + } + + private void addContainerParentColumns(List<ColumnConfig> configs, int dep, int maxDep) + { + if (dep <= maxDep) + { + configs.add(createContainerParentColumn(dep)); + addContainerParentColumns(configs, dep + 1, maxDep); + } + } + + private ColumnConfig createGeneratedFromParentColumn(int i) + { + ColumnConfig columnConfig = new ColumnConfig(); + columnConfig.setId(SampleModel.GENERATED_FROM_PARENT_PREFIX + i); + columnConfig.setHeader("Parent (gener.) " + i); + columnConfig.setWidth(150); + return columnConfig; + } + + private ColumnConfig createContainerParentColumn(int i) + { + ColumnConfig columnConfig = new ColumnConfig(); + columnConfig.setId(SampleModel.CONTAINER_PARENT_PREFIX + i); + columnConfig.setHeader("Parent (cont.) " + i); + columnConfig.setWidth(150); + return columnConfig; + } + +} \ No newline at end of file diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample_browser/SampleBrowser.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample_browser/SampleBrowser.java new file mode 100644 index 0000000000000000000000000000000000000000..78d06910112e4251210a63a6997c6c6876b63fbe --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample_browser/SampleBrowser.java @@ -0,0 +1,41 @@ +/* + * Copyright 2008 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.client.web.client.application.ui.sample_browser; + +import com.extjs.gxt.ui.client.Style.Orientation; +import com.extjs.gxt.ui.client.util.Margins; +import com.extjs.gxt.ui.client.widget.LayoutContainer; +import com.extjs.gxt.ui.client.widget.layout.RowData; +import com.extjs.gxt.ui.client.widget.layout.RowLayout; + +import ch.systemsx.cisd.openbis.generic.client.web.client.application.GenericViewContext; + +public class SampleBrowser extends LayoutContainer +{ + + public SampleBrowser(GenericViewContext viewContext) + { + setLayout(new RowLayout(Orientation.HORIZONTAL)); + + final RightPanel rightPanel = new RightPanel(viewContext); + final LeftPanel leftPanel = new LeftPanel(viewContext, rightPanel); + + add(leftPanel, new RowData(200, 1, new Margins(1))); + + add(rightPanel, new RowData(1, 1, new Margins(1))); + } +} \ No newline at end of file diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample_browser/SampleModel.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample_browser/SampleModel.java new file mode 100644 index 0000000000000000000000000000000000000000..5ff555588e1e31744f9d90f17729e6fe1d633917 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample_browser/SampleModel.java @@ -0,0 +1,89 @@ +/* + * Copyright 2008 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.client.web.client.application.ui.sample_browser; + +import com.extjs.gxt.ui.client.data.BaseModelData; + +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.Sample; + +/** + * @author Izabela Adamczyk + */ +public class SampleModel extends BaseModelData +{ + + static final String OBJECT = "object"; + + static final String SAMPLE_TYPE = "sampleType"; + + static final String SAMPLE_CODE = "code"; + + static final String ATTACHED_TO_IDENTIFIER = "attachedToIdentifier"; + + static final String SAMPLE_IDENTIFIER = "sampleIdentifier"; + + static final long serialVersionUID = 1L; + + public static final String REGISTRATOR = "registrator"; + + public static final String REGISTRATION_DATE = "registrationDate"; + + public static final String PROPERTY_PREFIX = "property"; + + public static final String CONTAINER_PARENT_PREFIX = "containerParent"; + + public static final String GENERATED_FROM_PARENT_PREFIX = "generatedFromParent"; + + public SampleModel(Sample s) + { + set(SAMPLE_CODE, s.getCode()); + set(SAMPLE_TYPE, s.getSampleType()); + set(OBJECT, s); + set(SAMPLE_IDENTIFIER, s.getIdentifier()); + set(ATTACHED_TO_IDENTIFIER, s.getGroup() != null ? s.getGroup().getIdentifier() : s + .getDatabaseInstance().getIdentifier()); + set(REGISTRATOR, s.getRegistrator()); + set(REGISTRATION_DATE, s.getRegistrationDate()); + setGeneratedFromParents(s, 1, s.getSampleType().getGeneratedFromHierarchyDepth()); + setContainerParents(s, 1, s.getSampleType().getPartOfHierarchyDepth()); + + } + + private void setGeneratedFromParents(Sample s, int dep, int maxDep) + { + if (dep <= maxDep && s.getGeneratedFrom() != null) + { + set(GENERATED_FROM_PARENT_PREFIX + dep, s.getGeneratedFrom().getIdentifier()); + setGeneratedFromParents(s.getGeneratedFrom(), dep + 1, maxDep); + } + } + + private void setContainerParents(Sample s, int dep, int maxDep) + { + if (dep <= maxDep && s.getContainer() != null) + { + set(CONTAINER_PARENT_PREFIX + dep, s.getContainer().getIdentifier()); + setContainerParents(s.getContainer(), dep + 1, maxDep); + } + } + + void setProperty(String code, String value) + { + set(PROPERTY_PREFIX + code, value); + } + +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample_browser/SampleTypeModel.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample_browser/SampleTypeModel.java new file mode 100644 index 0000000000000000000000000000000000000000..05444b70c79a3b71dd09e4674df6ceb3dfc69bff --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample_browser/SampleTypeModel.java @@ -0,0 +1,37 @@ +/* + * Copyright 2008 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.client.web.client.application.ui.sample_browser; + +import com.extjs.gxt.ui.client.data.BaseModelData; + +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.SampleType; + +/** + * @author Izabela Adamczyk + */ +public class SampleTypeModel extends BaseModelData +{ + + private static final long serialVersionUID = 1L; + + public SampleTypeModel(SampleType sampleType) + { + set("code", sampleType.getCode()); + set("object", sampleType); + } + +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample_browser/SampleTypeSelectionWidget.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample_browser/SampleTypeSelectionWidget.java new file mode 100644 index 0000000000000000000000000000000000000000..7400c6e08a94890e120644f9fd0632fc5ada32ac --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample_browser/SampleTypeSelectionWidget.java @@ -0,0 +1,51 @@ +/* + * Copyright 2008 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.client.web.client.application.ui.sample_browser; + +import java.util.List; + +import com.extjs.gxt.ui.client.store.ListStore; +import com.extjs.gxt.ui.client.widget.form.ComboBox; + +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.SampleType; + +class SampleTypeSelectionWidget extends ComboBox<SampleTypeModel> +{ + + public SampleTypeSelectionWidget(ListStore<SampleTypeModel> sampleTypes) + { + + setEmptyText("Select a sample type..."); + setDisplayField("code"); + setAllowBlank(false); + setEditable(false); + setStore(sampleTypes); + } + + public SampleType tryGetSelected() + { + + final List<SampleTypeModel> selection = getSelection(); + if (selection.size() > 0) + { + return selection.get(0).get("object"); + } else + { + return null; + } + } +} \ No newline at end of file diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/util/ClientConstants.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/util/ClientConstants.java index 49c9cf376fe71ae6b97261b0582bdb013f068206..81c181cd3df784c0098ac8d6310531bb72b2d985 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/util/ClientConstants.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/util/ClientConstants.java @@ -43,4 +43,6 @@ public class ClientConstants public static final int COL_PERSON_ID = 80; + public static final int COL_SAMPLE = 200; + } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/dto/DatabaseInstance.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/dto/DatabaseInstance.java index ca1c74e2d9ffe4dffe0669cf9b2dc3956b34a497..a65c408be3c19912d95a82c8b60ef09f99b19ae1 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/dto/DatabaseInstance.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/dto/DatabaseInstance.java @@ -19,16 +19,16 @@ package ch.systemsx.cisd.openbis.generic.client.web.client.dto; import com.google.gwt.user.client.rpc.IsSerializable; /** - * - * * @author Franz-Josef Elmer */ public class DatabaseInstance implements IsSerializable { private String code; - + private String uuid; + private String identifier; + public final String getCode() { return code; @@ -48,4 +48,14 @@ public class DatabaseInstance implements IsSerializable { this.uuid = uuid; } + + public String getIdentifier() + { + return identifier; + } + + public void setIdentifier(String identifier) + { + this.identifier = identifier; + } } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/dto/Group.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/dto/Group.java index 6d95d61a9aba3e08d16dbd36ae094a91901e622e..93d3e4b236c46fa41dfd24a113bb6b24b905e22c 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/dto/Group.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/dto/Group.java @@ -41,6 +41,8 @@ public class Group implements IsSerializable private DataStore dataStore; + private String identifier; + public final String getCode() { return code; @@ -120,4 +122,14 @@ public class Group implements IsSerializable { this.dataStore = dataStore; } + + public String getIdentifier() + { + return identifier; + } + + public void setIdentifier(String identifier) + { + this.identifier = identifier; + } } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/dto/Sample.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/dto/Sample.java new file mode 100644 index 0000000000000000000000000000000000000000..667e38521e71becc8cd0e5e7ee5e45f7530ecc1c --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/dto/Sample.java @@ -0,0 +1,138 @@ +/* + * Copyright 2008 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.client.web.client.dto; + +import java.util.Date; + +import com.google.gwt.user.client.rpc.IsSerializable; + +/** + * @author Izabela Adamczyk + */ +public class Sample implements IsSerializable +{ + + String code; + + SampleType sampleType; + + private Group group; + + DatabaseInstance databaseInstance; + + private String identifier; + + private Person registrator; + + private Date registrationDate; + + private Sample container; + + private Sample generatedFrom; + + public String getCode() + { + return code; + } + + public void setCode(String code) + { + this.code = code; + } + + public SampleType getSampleType() + { + return sampleType; + } + + public void setSampleType(SampleType sampleType) + { + this.sampleType = sampleType; + } + + public void setGroup(Group group) + { + this.group = group; + + } + + public Group getGroup() + { + return group; + } + + public DatabaseInstance getDatabaseInstance() + { + return databaseInstance; + } + + public void setDatabaseInstance(DatabaseInstance databaseInstance) + { + this.databaseInstance = databaseInstance; + } + + public String getIdentifier() + { + return identifier; + } + + public void setIdentifier(String identifier) + { + this.identifier = identifier; + } + + public Person getRegistrator() + { + return registrator; + } + + public void setRegistrator(Person registrator) + { + this.registrator = registrator; + } + + public Date getRegistrationDate() + { + return registrationDate; + } + + public void setRegistrationDate(Date registrationDate) + { + this.registrationDate = registrationDate; + } + + public Sample getContainer() + { + return container; + } + + public void setContainer(Sample container) + { + this.container = container; + } + + public Sample getGeneratedFrom() + { + return generatedFrom; + } + + public void setGeneratedFrom(Sample generatedFrom) + { + this.generatedFrom = generatedFrom; + } + +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/dto/SampleType.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/dto/SampleType.java new file mode 100644 index 0000000000000000000000000000000000000000..844aa996726ab0451e82085daa0f0181da1f1b9c --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/dto/SampleType.java @@ -0,0 +1,87 @@ +/* + * Copyright 2008 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.client.web.client.dto; + +import com.google.gwt.user.client.rpc.IsSerializable; + +/** + * @author Izabela Adamczyk + */ +public class SampleType implements IsSerializable +{ + + String code; + + String description; + + DatabaseInstance databaseInstance; + + private int generatedFromHierarchyDepth; + + private int partOfHierarchyDepth; + + public String getCode() + { + return code; + } + + public void setCode(String codel) + { + this.code = codel; + } + + public String getDescription() + { + return description; + } + + public void setDescription(String description) + { + this.description = description; + } + + public DatabaseInstance getDatabaseInstance() + { + return databaseInstance; + } + + public void setDatabaseInstance(DatabaseInstance databaseInstance) + { + this.databaseInstance = databaseInstance; + } + + public void setGeneratedFromHierarchyDepth(int generatedFromHierarchyDepth) + { + this.generatedFromHierarchyDepth = generatedFromHierarchyDepth; + } + + public void setPartOfHierarchyDepth(int partOfHierarchyDepth) + { + this.partOfHierarchyDepth = partOfHierarchyDepth; + } + + public int getGeneratedFromHierarchyDepth() + { + return generatedFromHierarchyDepth; + } + + public int getPartOfHierarchyDepth() + { + return partOfHierarchyDepth; + } + +} 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 af7a1f7ed9e8de5577ebea6189d7a2fb435ff2c8..0df1ee13d84baefd5166b2cf8c72a31978358eed 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 @@ -20,7 +20,7 @@ import com.google.gwt.user.client.rpc.IsSerializable; /** * User information to be shown in Web client. - * + * * @author Franz-Josef Elmer */ public final class User implements IsSerializable @@ -32,7 +32,7 @@ public final class User implements IsSerializable public User() { } - + public User(String userName, String homeGroupCodeOrNull) { this.userName = userName; @@ -59,4 +59,5 @@ public final class User implements IsSerializable { this.userName = userName; } + } \ No newline at end of file diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/GenericClientService.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/GenericClientService.java index 25e7ba4eef2cf02c7bb8b5343ec2d2742f159da0..bcf90d83a975d8d7b7d170d16194efc78eddde09 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/GenericClientService.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/GenericClientService.java @@ -34,17 +34,23 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.dto.ApplicationInfo; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.Group; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.Person; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.RoleAssignment; +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.Sample; +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.SampleType; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.SessionContext; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.User; import ch.systemsx.cisd.openbis.generic.client.web.server.util.GroupTranslater; import ch.systemsx.cisd.openbis.generic.client.web.server.util.PersonTranslator; import ch.systemsx.cisd.openbis.generic.client.web.server.util.RoleAssignmentTranslator; +import ch.systemsx.cisd.openbis.generic.client.web.server.util.SampleTranslator; +import ch.systemsx.cisd.openbis.generic.client.web.server.util.SampleTypeTranslator; import ch.systemsx.cisd.openbis.generic.client.web.server.util.UserFailureExceptionTranslater; import ch.systemsx.cisd.openbis.generic.shared.IGenericServer; import ch.systemsx.cisd.openbis.generic.shared.dto.GroupPE; import ch.systemsx.cisd.openbis.generic.shared.dto.PersonPE; import ch.systemsx.cisd.openbis.generic.shared.dto.RoleAssignmentPE; import ch.systemsx.cisd.openbis.generic.shared.dto.RoleCode; +import ch.systemsx.cisd.openbis.generic.shared.dto.SamplePE; +import ch.systemsx.cisd.openbis.generic.shared.dto.SampleTypePE; import ch.systemsx.cisd.openbis.generic.shared.dto.Session; import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.DatabaseInstanceIdentifier; import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.GroupIdentifier; @@ -354,4 +360,39 @@ public class GenericClientService implements IGenericClientService } + public List<SampleType> listSampleTypes() + { + try + { + List<SampleTypePE> sampleTypes = server.listSampleTypes(getSessionToken()); + List<SampleType> result = new ArrayList<SampleType>(); + for (SampleTypePE sampleTypePE : sampleTypes) + { + result.add(SampleTypeTranslator.translate(sampleTypePE)); + } + return result; + } catch (UserFailureException e) + { + throw UserFailureExceptionTranslater.translate(e); + } + } + + public List<Sample> listSamples(SampleType sampleType) + { + try + { + List<SamplePE> samples = + server.listSamples(getSessionToken(), SampleTypeTranslator + .translate(sampleType)); + List<Sample> result = new ArrayList<Sample>(); + for (SamplePE sample : samples) + { + result.add(SampleTranslator.translate(sample)); + } + return result; + } catch (UserFailureException e) + { + throw UserFailureExceptionTranslater.translate(e); + } + } } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/GenericClientServiceServlet.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/GenericClientServiceServlet.java index 34ce42764d4e7489bf8002ebbd98cfb67833d2cb..4e50bf3e7df09467b6374a7171245b0c7367f11d 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/GenericClientServiceServlet.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/GenericClientServiceServlet.java @@ -37,6 +37,8 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.dto.ApplicationInfo; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.Group; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.Person; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.RoleAssignment; +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.Sample; +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.SampleType; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.SessionContext; import ch.systemsx.cisd.openbis.generic.client.web.client.exception.UserFailureException; @@ -168,4 +170,14 @@ public class GenericClientServiceServlet extends GWTSpringController implements } + public List<SampleType> listSampleTypes() throws UserFailureException + { + return service.listSampleTypes(); + } + + public List<Sample> listSamples(SampleType sampleType) throws UserFailureException + { + return service.listSamples(sampleType); + } + } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/util/InstanceTranslater.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/util/DatabaseInstanceTranslater.java similarity index 67% rename from openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/util/InstanceTranslater.java rename to openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/util/DatabaseInstanceTranslater.java index 6541d7fef52945106908c8d3425d3c9063e42551..118176d0049a935f952d540bc079c7e2961fe4be 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/util/InstanceTranslater.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/util/DatabaseInstanceTranslater.java @@ -18,11 +18,12 @@ package ch.systemsx.cisd.openbis.generic.client.web.server.util; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.DatabaseInstance; import ch.systemsx.cisd.openbis.generic.shared.dto.DatabaseInstancePE; +import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.IdentifierHelper; /** * @author Izabela Adamczyk */ -public class InstanceTranslater +public class DatabaseInstanceTranslater { public static DatabaseInstance translate(DatabaseInstancePE databaseInstance) @@ -34,6 +35,19 @@ public class InstanceTranslater DatabaseInstance result = new DatabaseInstance(); result.setCode(databaseInstance.getCode()); result.setUuid(databaseInstance.getUuid()); + result.setIdentifier(IdentifierHelper.createIdentifier(databaseInstance).toString()); + return result; + } + + public static DatabaseInstancePE translate(DatabaseInstance databaseInstance) + { + if (databaseInstance == null) + { + return null; + } + DatabaseInstancePE result = new DatabaseInstancePE(); + result.setCode(databaseInstance.getCode()); + result.setUuid(databaseInstance.getUuid()); return result; } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/util/GroupTranslater.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/util/GroupTranslater.java index 86b047356ba791e1babf59949155c33d3b64eb45..d8602cba1a395069db09955f1a6dbaa511d6200f 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/util/GroupTranslater.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/util/GroupTranslater.java @@ -18,10 +18,9 @@ package ch.systemsx.cisd.openbis.generic.client.web.server.util; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.Group; import ch.systemsx.cisd.openbis.generic.shared.dto.GroupPE; +import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.IdentifierHelper; /** - * - * * @author Franz-Josef Elmer */ public class GroupTranslater @@ -29,7 +28,7 @@ public class GroupTranslater private GroupTranslater() { } - + public static Group translate(GroupPE group) { if (group == null) @@ -41,6 +40,7 @@ public class GroupTranslater result.setDescription(group.getDescription()); result.setRegistrationDate(group.getRegistrationDate()); result.setRegistrator(PersonTranslator.translate(group.getRegistrator())); + result.setIdentifier(IdentifierHelper.createIdentifier(group).toString()); return result; } } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/util/RoleAssignmentTranslator.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/util/RoleAssignmentTranslator.java index 1ad2a1c3f59638ef8ed5e0699169c16a2605339b..ba25e8288a1f3a61888f1087be9100dda5245c2e 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/util/RoleAssignmentTranslator.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/util/RoleAssignmentTranslator.java @@ -33,7 +33,7 @@ public class RoleAssignmentTranslator } RoleAssignment result = new RoleAssignment(); result.setGroup(GroupTranslater.translate(role.getGroup())); - result.setInstance(InstanceTranslater.translate(role.getDatabaseInstance())); + result.setInstance(DatabaseInstanceTranslater.translate(role.getDatabaseInstance())); result.setPerson(PersonTranslator.translate(role.getPerson())); result.setCode(getRoleCode(role)); return result; diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/util/SampleTranslator.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/util/SampleTranslator.java new file mode 100644 index 0000000000000000000000000000000000000000..cb382f97dd10ca8ba69488d8f7f1da72872c21ea --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/util/SampleTranslator.java @@ -0,0 +1,67 @@ +/* + * Copyright 2008 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.client.web.server.util; + +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.Sample; +import ch.systemsx.cisd.openbis.generic.shared.dto.SamplePE; + +/** + * @author Franz-Josef Elmer + */ +public class SampleTranslator +{ + private SampleTranslator() + { + } + + public static Sample translate(SamplePE samplePE) + { + if (samplePE == null) + { + return null; + } + int containerDep = samplePE.getSampleType().getContainerHierarchyDepth(); + int generatedFromDep = samplePE.getSampleType().getGeneratedFromHierarchyDepth(); + return translate(samplePE, containerDep, generatedFromDep); + + } + + private static Sample translate(SamplePE samplePE, int containerDep, int generatedFromDep) + { + final Sample result = new Sample(); + result.setCode(samplePE.getCode()); + result.setSampleType(SampleTypeTranslator.translate(samplePE.getSampleType())); + result.setGroup(GroupTranslater.translate(samplePE.getGroup())); + result.setDatabaseInstance(DatabaseInstanceTranslater.translate(samplePE + .getDatabaseInstance())); + result.setIdentifier(samplePE.getSampleIdentifier().toString()); + result.setRegistrator(PersonTranslator.translate(samplePE.getRegistrator())); + result.setRegistrationDate(samplePE.getRegistrationDate()); + if (containerDep > 0 && samplePE.getContainer() != null) + { + result.setContainer(SampleTranslator.translate(samplePE.getContainer(), + containerDep - 1, 0)); + } + if (generatedFromDep > 0 && samplePE.getGeneratedFrom() != null) + { + result.setGeneratedFrom(SampleTranslator.translate(samplePE.getGeneratedFrom(), 0, + generatedFromDep - 1)); + } + return result; + } + +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/util/SampleTypeTranslator.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/util/SampleTypeTranslator.java new file mode 100644 index 0000000000000000000000000000000000000000..3af38863f2fb0d3c234ab1f416f25bcabab7f1c8 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/util/SampleTypeTranslator.java @@ -0,0 +1,50 @@ +/* + * Copyright 2008 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.client.web.server.util; + +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.SampleType; +import ch.systemsx.cisd.openbis.generic.shared.dto.SampleTypePE; + +/** + * @author Franz-Josef Elmer + */ +public class SampleTypeTranslator +{ + private SampleTypeTranslator() + { + } + + public static SampleType translate(SampleTypePE sampleTypePE) + { + final SampleType result = new SampleType(); + result.setCode(sampleTypePE.getCode()); + result.setDescription(sampleTypePE.getDescription()); + result.setGeneratedFromHierarchyDepth(sampleTypePE.getGeneratedFromHierarchyDepth()); + result.setPartOfHierarchyDepth(sampleTypePE.getContainerHierarchyDepth()); + return result; + + } + + public static SampleTypePE translate(SampleType sampleType) + { + final SampleTypePE result = new SampleTypePE(); + result.setCode(sampleType.getCode()); + return result; + + } + +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/GenericServer.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/GenericServer.java index 4aa629f481c82e555f826d1e1e1a8ad88032049b..1cd1139a574514889cc8b1f608de1b027b34aaa1 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/GenericServer.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/GenericServer.java @@ -130,6 +130,7 @@ public class GenericServer implements IGenericServer, ISessionProvider, @Transactional public Session tryToAuthenticate(String user, String password) { + System.err.println(user + " " + password); String sessionToken = sessionManager.tryToOpenSession(user, password); if (sessionToken == null) { @@ -335,7 +336,8 @@ public class GenericServer implements IGenericServer, ISessionProvider, public List<SamplePE> listSamples(String sessionToken, SampleTypePE sampleType) { Session session = sessionManager.getSession(sessionToken); - return boFactory.createSampleBO(session).listSamples(sampleType); + final List<SamplePE> samples = boFactory.createSampleBO(session).listSamples(sampleType); + return samples; } } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/SampleBO.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/SampleBO.java index 3edd28eef8fb3b17d7989f1bec37e8bda547f9e0..44f8b81f844cde7de1f47ee4d71b0f3770527c98 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/SampleBO.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/SampleBO.java @@ -40,7 +40,8 @@ public class SampleBO extends AbstractBusinessObject implements ISampleBO SampleTypePE sampleType = getSampleTypeDAO().tryFindByExample(sampleTypeExample); if (sampleType == null) { - throw new UserFailureException("Cannot find a type matching to " + sampleTypeExample); + throw new UserFailureException("Cannot find a sample type matching to " + + sampleTypeExample); } return getSampleDAO().listSamples(sampleType); } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/SampleType.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/SampleType.java index 50382371e4e3b50d47b829bf3a8a59874c05e93f..22248baaf4dd1026e5dd6021aef1fab24fbb0437 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/SampleType.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/SampleType.java @@ -29,11 +29,15 @@ public final class SampleType extends EntityType private static final long serialVersionUID = GenericSharedConstants.VERSION; public static final SampleType[] EMPTY_ARRAY = new SampleType[0]; - + private boolean plate; private boolean controlLayout; + private int generatedFromHierarchyDepth; + + private int partOfHierarchyDepth; + public final boolean isPlate() { return plate; @@ -53,4 +57,26 @@ public final class SampleType extends EntityType { this.controlLayout = controlLayout; } + + public void setGeneratedFromHierarchyDepth(int generatedFromHierarchyDepth) + { + this.generatedFromHierarchyDepth = generatedFromHierarchyDepth; + + } + + public void setPartOfHierarchyDepth(int partOfHierarchyDepth) + { + this.partOfHierarchyDepth = partOfHierarchyDepth; + + } + + public int getGeneratedFromHierarchyDepth() + { + return generatedFromHierarchyDepth; + } + + public int getPartOfHierarchyDepth() + { + return partOfHierarchyDepth; + } } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/SampleTypePE.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/SampleTypePE.java index 2d2c57aa97810b20681705a2c28072190ad6365a..0c142c25a647525eecea9d18f014ccb294724332 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/SampleTypePE.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/SampleTypePE.java @@ -43,14 +43,14 @@ public final class SampleTypePE extends EntityTypePE { private static final long serialVersionUID = GenericSharedConstants.VERSION; - private boolean isListable; + private Boolean isListable; - private int generatedFromHierarchyDepth; + private Integer generatedFromHierarchyDepth; - private int containerHierarchyDepth; + private Integer containerHierarchyDepth; @Column(name = ColumnNames.IS_LISTABLE) - public boolean isListable() + public Boolean isListable() { return isListable; } @@ -61,7 +61,7 @@ public final class SampleTypePE extends EntityTypePE } @Column(name = ColumnNames.GENERATED_FROM_DEPTH) - public int getGeneratedFromHierarchyDepth() + public Integer getGeneratedFromHierarchyDepth() { return generatedFromHierarchyDepth; } @@ -72,7 +72,7 @@ public final class SampleTypePE extends EntityTypePE } @Column(name = ColumnNames.PART_OF_DEPTH) - public int getContainerHierarchyDepth() + public Integer getContainerHierarchyDepth() { return containerHierarchyDepth; } diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/AuthorizationManagementConsolTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/AuthorizationManagementConsolTest.java index cb0ce3315132b24048c339b3669b60ef01370111..aa974e8fd10e58418a73dab47642834b0c3a2ac6 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/AuthorizationManagementConsolTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/AuthorizationManagementConsolTest.java @@ -16,9 +16,9 @@ package ch.systemsx.cisd.openbis.generic.client.web.client.application; -import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.CheckGroup; -import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.CreateGroup; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.Login; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.amc.CheckGroup; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.amc.CreateGroup; import ch.systemsx.cisd.openbis.generic.client.web.client.testframework.AbstractGWTTestCase; /** diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/CheckGroup.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/amc/CheckGroup.java similarity index 99% rename from openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/CheckGroup.java rename to openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/amc/CheckGroup.java index 60339f5d4d0a2b1d3ed59346c8220d86bd5e75e9..dbc00e105edbdacf05d4813ec64aff73f7461402 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/CheckGroup.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/amc/CheckGroup.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package ch.systemsx.cisd.openbis.generic.client.web.client.application.ui; +package ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.amc; import junit.framework.Assert; diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/CreateGroup.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/amc/CreateGroup.java similarity index 98% rename from openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/CreateGroup.java rename to openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/amc/CreateGroup.java index 12f77e425993f8c89cabe3d57eb322fc4ff228e6..264ddc2f12cb281efec5aa656b0ebbf986e8ca83 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/CreateGroup.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/amc/CreateGroup.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package ch.systemsx.cisd.openbis.generic.client.web.client.application.ui; +package ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.amc; import ch.systemsx.cisd.openbis.generic.client.web.client.testframework.AbstractDefaultTestCommand; import ch.systemsx.cisd.openbis.generic.client.web.client.testframework.GWTTestUtil;