Skip to content
Snippets Groups Projects
Commit 1ef7a5a2 authored by felmer's avatar felmer
Browse files

ExperimentBrowser: Change column ID GROUP -> SPACE. ExperimentProviderTest added.

SVN: 21500
parent a69ceaf5
No related branches found
No related tags found
No related merge requests found
......@@ -27,7 +27,7 @@ public class ExperimentBrowserGridColumnIDs
public static final String EXPERIMENT_TYPE = "EXPERIMENT_TYPE";
public static final String EXPERIMENT_IDENTIFIER = "EXPERIMENT_IDENTIFIER";
public static final String DATABASE_INSTANCE = "DATABASE_INSTANCE";
public static final String GROUP = "GROUP";
public static final String SPACE = "SPACE";
public static final String PROJECT = "PROJECT";
public static final String REGISTRATOR = "REGISTRATOR";
public static final String REGISTRATION_DATE = "REGISTRATION_DATE";
......
......@@ -20,7 +20,7 @@ import static ch.systemsx.cisd.openbis.generic.client.web.client.dto.ExperimentB
import static ch.systemsx.cisd.openbis.generic.client.web.client.dto.ExperimentBrowserGridColumnIDs.DATABASE_INSTANCE;
import static ch.systemsx.cisd.openbis.generic.client.web.client.dto.ExperimentBrowserGridColumnIDs.EXPERIMENT_IDENTIFIER;
import static ch.systemsx.cisd.openbis.generic.client.web.client.dto.ExperimentBrowserGridColumnIDs.EXPERIMENT_TYPE;
import static ch.systemsx.cisd.openbis.generic.client.web.client.dto.ExperimentBrowserGridColumnIDs.GROUP;
import static ch.systemsx.cisd.openbis.generic.client.web.client.dto.ExperimentBrowserGridColumnIDs.SPACE;
import static ch.systemsx.cisd.openbis.generic.client.web.client.dto.ExperimentBrowserGridColumnIDs.IS_INVALID;
import static ch.systemsx.cisd.openbis.generic.client.web.client.dto.ExperimentBrowserGridColumnIDs.PERM_ID;
import static ch.systemsx.cisd.openbis.generic.client.web.client.dto.ExperimentBrowserGridColumnIDs.PROJECT;
......@@ -72,7 +72,7 @@ public class ExperimentProvider extends AbstractCommonTableModelProvider<Experim
builder.addColumn(EXPERIMENT_TYPE).hideByDefault();
builder.addColumn(EXPERIMENT_IDENTIFIER).hideByDefault().withDefaultWidth(150);
builder.addColumn(DATABASE_INSTANCE).hideByDefault();
builder.addColumn(GROUP).hideByDefault();
builder.addColumn(SPACE).hideByDefault();
builder.addColumn(PROJECT).hideByDefault();
builder.addColumn(REGISTRATOR);
builder.addColumn(REGISTRATION_DATE).withDefaultWidth(200);
......@@ -87,7 +87,7 @@ public class ExperimentProvider extends AbstractCommonTableModelProvider<Experim
builder.column(EXPERIMENT_TYPE).addString(experiment.getExperimentType().getCode());
builder.column(EXPERIMENT_IDENTIFIER).addString(experiment.getIdentifier());
builder.column(DATABASE_INSTANCE).addString(experiment.getProject().getSpace().getInstance().getCode());
builder.column(GROUP).addString(experiment.getProject().getSpace().getCode());
builder.column(SPACE).addString(experiment.getProject().getSpace().getCode());
builder.column(PROJECT).addString(experiment.getProject().getCode());
builder.column(REGISTRATOR).addPerson(experiment.getRegistrator());
builder.column(REGISTRATION_DATE).addDate(experiment.getRegistrationDate());
......
/*
* Copyright 2011 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.resultset;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import org.jmock.Expectations;
import org.testng.annotations.Test;
import ch.systemsx.cisd.openbis.generic.client.web.client.dto.ListExperimentsCriteria;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataTypeCode;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Experiment;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ExperimentType;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Project;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Space;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.TableModelRowWithObject;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.TypedTableModel;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.builders.ExperimentBuilder;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.builders.ExperimentTypeBuilder;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.builders.PersonBuilder;
import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.ProjectIdentifier;
/**
*
*
* @author Franz-Josef Elmer
*/
public class ExperimentProviderTest extends AbstractProviderTest
{
@Test
public void test()
{
ListExperimentsCriteria criteria = new ListExperimentsCriteria();
final ExperimentType experimentType = new ExperimentType();
criteria.setExperimentType(experimentType);
Project project = new Project();
project.setCode("project");
Space space = new Space();
space.setCode("space");
project.setSpace(space);
criteria.setProject(project);
final ExperimentBuilder e1 =
new ExperimentBuilder()
.code("E1")
.identifier("DB:/A/B/E1")
.date(new Date(1000123456))
.invalidate()
.permID("123-45")
.type("1")
.registrator(
new PersonBuilder().name("Albert", "Einstein").userID("ae")
.getPerson()).property("NUMBER", "42");
context.checking(new Expectations()
{
{
one(server).listExperimentTypes(SESSION_TOKEN);
ExperimentType type1 =
new ExperimentTypeBuilder().code("1")
.propertyType("TEXT", "text", DataTypeCode.MULTILINE_VARCHAR)
.propertyType("NUMBER", "number", DataTypeCode.REAL)
.getExperimentType();
will(returnValue(Arrays.asList(type1)));
one(server).listExperiments(SESSION_TOKEN, experimentType,
new ProjectIdentifier("space", "project"));
will(returnValue(Arrays.asList(e1.getExperiment())));
}
});
TypedTableModel<Experiment> tableModel =
new ExperimentProvider(server, SESSION_TOKEN, criteria).getTableModel(100);
assertEquals("[CODE, EXPERIMENT_TYPE, EXPERIMENT_IDENTIFIER, DATABASE_INSTANCE, SPACE, "
+ "PROJECT, REGISTRATOR, REGISTRATION_DATE, IS_INVALID, PERM_ID, "
+ "SHOW_DETAILS_LINK, property-USER-NUMBER, property-USER-TEXT]",
getHeaderIDs(tableModel).toString());
assertEquals("[VARCHAR, VARCHAR, VARCHAR, VARCHAR, VARCHAR, VARCHAR, VARCHAR, TIMESTAMP, "
+ "VARCHAR, VARCHAR, VARCHAR, VARCHAR, MULTILINE_VARCHAR]",
getHeaderDataTypes(tableModel).toString());
assertEquals("[null, null, null, null, null, null, null, null, null, null, "
+ "null, null, null]", getHeaderEntityKinds(tableModel).toString());
List<TableModelRowWithObject<Experiment>> rows = tableModel.getRows();
assertSame(e1.getExperiment(), rows.get(0).getObjectOrNull());
assertEquals("[E1, 1, DB:/A/B/E1, DB, A, B, Einstein, Albert, Mon Jan 12 14:48:43 CET 1970, "
+ "yes, 123-45, , 42, ]", rows.get(0).getValues().toString());
context.assertIsSatisfied();
}
}
......@@ -103,6 +103,12 @@ public class ExperimentBuilder
return this;
}
public ExperimentBuilder registrator(Person registrator)
{
experiment.setRegistrator(registrator);
return this;
}
public ExperimentBuilder date(Date date)
{
experiment.setRegistrationDate(date);
......
/*
* Copyright 2011 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.builders;
import java.util.ArrayList;
import java.util.List;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataType;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataTypeCode;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.PropertyType;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ExperimentType;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ExperimentTypePropertyType;
/**
*
*
* @author Franz-Josef Elmer
*/
public class ExperimentTypeBuilder extends AbstractEntityTypeBuilder
{
private ExperimentType experimentType = new ExperimentType();
public ExperimentTypeBuilder()
{
experimentType.setExperimentTypePropertyTypes(new ArrayList<ExperimentTypePropertyType>());
}
public ExperimentTypeBuilder code(String code)
{
experimentType.setCode(code);
return this;
}
public ExperimentType getExperimentType()
{
return experimentType;
}
public ExperimentTypeBuilder propertyType(String code, String label, DataTypeCode dataType)
{
addPropertyType(experimentType, new ExperimentTypePropertyType(), code, label, dataType);
return this;
}
protected void addPropertyType(ExperimentType entityType, ExperimentTypePropertyType entityTypePropertyType, String code, String label,
DataTypeCode type)
{
List<ExperimentTypePropertyType> types = entityType.getAssignedPropertyTypes();
PropertyType propertyType = new PropertyType();
propertyType.setCode(code);
propertyType.setSimpleCode(code);
propertyType.setLabel(label);
propertyType.setDataType(new DataType(type));
entityTypePropertyType.setPropertyType(propertyType);
entityTypePropertyType.setEntityType(entityType);
types.add(entityTypePropertyType);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment