diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/CommonClientService.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/CommonClientService.java index 5af5b63380512ab62258293e3c5145e6b3d60757..3986b05781f7e8d11c4c99bd58b2bc211c049eb7 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/CommonClientService.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/CommonClientService.java @@ -21,12 +21,6 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import javax.annotation.Resource; - -import org.springframework.stereotype.Component; - -import ch.rinn.restrictions.Friend; -import ch.rinn.restrictions.Private; import ch.systemsx.cisd.common.exceptions.UserFailureException; import ch.systemsx.cisd.common.servlet.IRequestContextProvider; import ch.systemsx.cisd.common.utilities.BeanUtils; @@ -76,25 +70,16 @@ import ch.systemsx.cisd.openbis.plugin.AbstractClientService; * * @author Franz-Josef Elmer */ -@Component(value = ch.systemsx.cisd.openbis.generic.shared.ResourceNames.COMMON_SERVICE) -@Friend(toClasses = AbstractClientService.class) public final class CommonClientService extends AbstractClientService implements ICommonClientService { - - @Resource(name = ch.systemsx.cisd.openbis.generic.shared.ResourceNames.COMMON_SERVER) private ICommonServer commonServer; - public CommonClientService() - { - } - - @Private - CommonClientService(final ICommonServer genericServer, + public CommonClientService(final ICommonServer commonServer, final IRequestContextProvider requestContextProvider) { super(requestContextProvider); - this.commonServer = genericServer; + this.commonServer = commonServer; } @SuppressWarnings("unchecked") @@ -209,8 +194,8 @@ public final class CommonClientService extends AbstractClientService implements final GroupIdentifier groupIdentifier = new GroupIdentifier(DatabaseInstanceIdentifier.HOME, group); final String sessionToken = getSessionToken(); - commonServer.registerGroupRole(sessionToken, - RoleCodeTranslator.translate(roleSetCode), groupIdentifier, person); + commonServer.registerGroupRole(sessionToken, RoleCodeTranslator.translate(roleSetCode), + groupIdentifier, person); } catch (final UserFailureException e) { throw UserFailureExceptionTranslator.translate(e); @@ -255,8 +240,8 @@ public final class CommonClientService extends AbstractClientService implements try { final String sessionToken = getSessionToken(); - commonServer.deleteInstanceRole(sessionToken, RoleCodeTranslator - .translate(roleSetCode), person); + commonServer.deleteInstanceRole(sessionToken, + RoleCodeTranslator.translate(roleSetCode), person); } catch (final UserFailureException e) { throw UserFailureExceptionTranslator.translate(e); diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/CommonClientServiceServlet.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/CommonClientServiceServlet.java index afc3c25219b8d9e0ec3e49c9d3bc07a52754b264..10fe3ff072654f88f22ee1bb132216fdddf5a017 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/CommonClientServiceServlet.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/CommonClientServiceServlet.java @@ -23,6 +23,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import ch.systemsx.cisd.common.servlet.GWTRPCServiceExporter; import ch.systemsx.cisd.openbis.generic.client.web.client.ICommonClientService; +import ch.systemsx.cisd.openbis.generic.shared.ResourceNames; /** * The {@link GWTRPCServiceExporter} for the <i>generic</i> service. @@ -41,7 +42,7 @@ public final class CommonClientServiceServlet extends GWTRPCServiceExporter { private static final long serialVersionUID = 1L; - @Resource(name = ch.systemsx.cisd.openbis.generic.shared.ResourceNames.COMMON_SERVICE) + @Resource(name = ResourceNames.COMMON_SERVICE) private ICommonClientService service; // 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 fa905308cc434d80073d3f9b9d3eb64134482b73..98e8112ea5c7915178e5b9bb625dc43a0e9120c2 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 @@ -31,7 +31,6 @@ import ch.systemsx.cisd.common.logging.LogCategory; import ch.systemsx.cisd.common.logging.LogFactory; import ch.systemsx.cisd.common.spring.IInvocationLoggerFactory; import ch.systemsx.cisd.common.spring.LogInterceptor; -import ch.systemsx.cisd.openbis.generic.server.business.bo.IGenericBusinessObjectFactory; import ch.systemsx.cisd.openbis.generic.server.dataaccess.IDAOFactory; import ch.systemsx.cisd.openbis.generic.shared.IServer; import ch.systemsx.cisd.openbis.generic.shared.dto.IAuthSession; @@ -40,7 +39,6 @@ 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.Session; import ch.systemsx.cisd.openbis.generic.shared.util.HibernateUtils; -import ch.systemsx.cisd.openbis.plugin.generic.shared.ResourceNames; /** * An <i>abstract</i> {@link IServer} implementation. @@ -62,9 +60,6 @@ public abstract class AbstractServer<T extends IServer> implements IServer, @Resource(name = ComponentNames.LOG_INTERCEPTOR) private LogInterceptor logInterceptor; - @Resource(name = ResourceNames.GENERIC_BUSINESS_OBJECT_FACTORY) - private IGenericBusinessObjectFactory businessObjectFactory; - private ProxyFactory proxyFactory; protected AbstractServer() @@ -74,11 +69,11 @@ public abstract class AbstractServer<T extends IServer> implements IServer, } protected AbstractServer(final ISessionManager<Session> sessionManager, - final IDAOFactory daoFactory, IGenericBusinessObjectFactory boFactory) + final IDAOFactory daoFactory) { + this(); this.sessionManager = sessionManager; this.daoFactory = daoFactory; - this.businessObjectFactory = boFactory; } private final ProxyFactory getProxyFactory() @@ -130,11 +125,6 @@ public abstract class AbstractServer<T extends IServer> implements IServer, "No system user could be found in given list '%s'.", persons)); } - protected final IGenericBusinessObjectFactory getBusinessObjectFactory() - { - return businessObjectFactory; - } - protected final ISessionManager<Session> getSessionManager() { return sessionManager; diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/CommonBusinessObjectFactory.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/CommonBusinessObjectFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..06fd42d6d3eaaca4076d52255d6c20724cd02258 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/CommonBusinessObjectFactory.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.server; + +import ch.systemsx.cisd.openbis.generic.server.business.bo.AbstractBusinessObjectFactory; +import ch.systemsx.cisd.openbis.generic.server.business.bo.EntityPropertiesConverter; +import ch.systemsx.cisd.openbis.generic.server.business.bo.ExternalDataTable; +import ch.systemsx.cisd.openbis.generic.server.business.bo.GroupBO; +import ch.systemsx.cisd.openbis.generic.server.business.bo.ICommonBusinessObjectFactory; +import ch.systemsx.cisd.openbis.generic.server.business.bo.IEntityPropertiesConverter; +import ch.systemsx.cisd.openbis.generic.server.business.bo.IExternalDataTable; +import ch.systemsx.cisd.openbis.generic.server.business.bo.IGroupBO; +import ch.systemsx.cisd.openbis.generic.server.business.bo.IRoleAssignmentTable; +import ch.systemsx.cisd.openbis.generic.server.business.bo.ISampleBO; +import ch.systemsx.cisd.openbis.generic.server.business.bo.ISampleTable; +import ch.systemsx.cisd.openbis.generic.server.business.bo.RoleAssignmentTable; +import ch.systemsx.cisd.openbis.generic.server.business.bo.SampleBO; +import ch.systemsx.cisd.openbis.generic.server.business.bo.SampleTable; +import ch.systemsx.cisd.openbis.generic.server.dataaccess.IDAOFactory; +import ch.systemsx.cisd.openbis.generic.shared.dto.Session; +import ch.systemsx.cisd.openbis.generic.shared.dto.properties.EntityKind; + +/** + * The unique {@link ICommonBusinessObjectFactory} implementation. + * + * @author Tomasz Pylak + */ +public final class CommonBusinessObjectFactory extends AbstractBusinessObjectFactory implements + ICommonBusinessObjectFactory +{ + public CommonBusinessObjectFactory(final IDAOFactory daoFactory) + { + super(daoFactory); + } + + // TODO 2008-12-01, Christian Ribeaud: Remove this. + private final IEntityPropertiesConverter createEntityPropertiesConverter( + final EntityKind entityKind) + { + return new EntityPropertiesConverter(entityKind, getDaoFactory()); + } + + // + // IGenericBusinessObjectFactory + // + + public final IGroupBO createGroupBO(final Session session) + { + return new GroupBO(getDaoFactory(), session); + } + + public final IRoleAssignmentTable createRoleAssignmentTable(final Session session) + { + return new RoleAssignmentTable(getDaoFactory(), session); + } + + public final ISampleTable createSampleTable(final Session session) + { + return new SampleTable(getDaoFactory(), session); + } + + public final ISampleBO createSampleBO(final Session session) + { + final IEntityPropertiesConverter converter = + createEntityPropertiesConverter(EntityKind.SAMPLE); + return new SampleBO(getDaoFactory(), converter, session); + } + + public final IExternalDataTable createExternalDataTable(final Session session) + { + return new ExternalDataTable(getDaoFactory(), session); + } +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/CommonServer.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/CommonServer.java index ea272d3b20a9da8e083e505f90883aa55ee06358..28a195f167da79c5f2e9f9dc9828dfbcd92aca64 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/CommonServer.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/CommonServer.java @@ -20,10 +20,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import javax.annotation.Resource; - import org.springframework.dao.DataAccessException; -import org.springframework.stereotype.Component; import ch.systemsx.cisd.authentication.IAuthenticationService; import ch.systemsx.cisd.authentication.ISessionManager; @@ -31,8 +28,8 @@ import ch.systemsx.cisd.authentication.Principal; import ch.systemsx.cisd.common.exceptions.EnvironmentFailureException; import ch.systemsx.cisd.common.exceptions.UserFailureException; import ch.systemsx.cisd.common.utilities.ParameterChecker; +import ch.systemsx.cisd.openbis.generic.server.business.bo.ICommonBusinessObjectFactory; import ch.systemsx.cisd.openbis.generic.server.business.bo.IExternalDataTable; -import ch.systemsx.cisd.openbis.generic.server.business.bo.IGenericBusinessObjectFactory; import ch.systemsx.cisd.openbis.generic.server.business.bo.IGroupBO; import ch.systemsx.cisd.openbis.generic.server.business.bo.IRoleAssignmentTable; import ch.systemsx.cisd.openbis.generic.server.business.bo.ISampleBO; @@ -64,22 +61,19 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.SampleIdentifier; * * @author Franz-Josef Elmer */ -@Component(ch.systemsx.cisd.openbis.generic.shared.ResourceNames.COMMON_SERVER) public final class CommonServer extends AbstractServer<ICommonServer> implements ICommonServer { - @Resource(name = ComponentNames.AUTHENTICATION_SERVICE) private IAuthenticationService authenticationService; - public CommonServer() - { - } + private ICommonBusinessObjectFactory businessObjectFactory; - CommonServer(final IAuthenticationService authenticationService, + public CommonServer(final IAuthenticationService authenticationService, final ISessionManager<Session> sessionManager, final IDAOFactory daoFactory, - final IGenericBusinessObjectFactory boFactory) + final ICommonBusinessObjectFactory businessObjectFactory) { - super(sessionManager, daoFactory, boFactory); + super(sessionManager, daoFactory); this.authenticationService = authenticationService; + this.businessObjectFactory = businessObjectFactory; } // @@ -128,7 +122,7 @@ public final class CommonServer extends AbstractServer<ICommonServer> implements final String descriptionOrNull, final String groupLeaderOrNull) { final Session session = getSessionManager().getSession(sessionToken); - final IGroupBO groupBO = getBusinessObjectFactory().createGroupBO(session); + final IGroupBO groupBO = businessObjectFactory.createGroupBO(session); groupBO.define(groupCode, descriptionOrNull, groupLeaderOrNull); groupBO.save(); } @@ -174,8 +168,7 @@ public final class CommonServer extends AbstractServer<ICommonServer> implements newRoleAssignment.setGroupIdentifier(groupIdentifier); newRoleAssignment.setRole(roleCode); - final IRoleAssignmentTable table = - getBusinessObjectFactory().createRoleAssignmentTable(session); + final IRoleAssignmentTable table = businessObjectFactory.createRoleAssignmentTable(session); table.add(newRoleAssignment); table.save(); @@ -192,8 +185,7 @@ public final class CommonServer extends AbstractServer<ICommonServer> implements DatabaseInstanceIdentifier.HOME)); newRoleAssignment.setRole(roleCode); - final IRoleAssignmentTable table = - getBusinessObjectFactory().createRoleAssignmentTable(session); + final IRoleAssignmentTable table = businessObjectFactory.createRoleAssignmentTable(session); table.add(newRoleAssignment); table.save(); @@ -274,7 +266,7 @@ public final class CommonServer extends AbstractServer<ICommonServer> implements final ListSampleCriteriaDTO criteria) { final Session session = getSessionManager().getSession(sessionToken); - final ISampleTable sampleTable = getBusinessObjectFactory().createSampleTable(session); + final ISampleTable sampleTable = businessObjectFactory.createSampleTable(session); sampleTable.loadSamplesByCriteria(criteria); sampleTable.enrichWithValidProcedure(); sampleTable.enrichWithProperties(); @@ -286,7 +278,7 @@ public final class CommonServer extends AbstractServer<ICommonServer> implements { final Session session = getSessionManager().getSession(sessionToken); final IExternalDataTable externalDataTable = - getBusinessObjectFactory().createExternalDataTable(session); + businessObjectFactory.createExternalDataTable(session); externalDataTable.loadBySampleIdentifier(identifier); return externalDataTable.getExternalData(); } @@ -316,7 +308,7 @@ public final class CommonServer extends AbstractServer<ICommonServer> implements { final Session session = getSessionManager().getSession(sessionToken); ParameterChecker.checkIfNotNull(newSample, "sample"); - final ISampleBO sampleBO = getBusinessObjectFactory().createSampleBO(session); + final ISampleBO sampleBO = businessObjectFactory.createSampleBO(session); sampleBO.define(newSample); sampleBO.save(); } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/ComponentNames.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/ComponentNames.java index 886fc9a06f58a34de1771d96b5bb72c919fe0687..adf1e4c8c61e2d89ef86412567385f0d8919299e 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/ComponentNames.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/ComponentNames.java @@ -26,6 +26,7 @@ public final class ComponentNames private ComponentNames() { + // Can not be instantiated. } public final static String AUTHENTICATION_SERVICE = "authentication-service"; @@ -35,4 +36,6 @@ public final class ComponentNames public static final String LOG_INTERCEPTOR = "log-interceptor"; public static final String DAO_FACTORY = "dao-factory"; + + public static final String COMMON_BUSINESS_OBJECT_FACTORY = "common-business-object-factory"; } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/AbstractBusinessObjectFactory.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/AbstractBusinessObjectFactory.java index ae32de2ccdbd25a92c56d7bda86dce5e56ce6ee5..2ba222d2d596aa9630b5ccf00981d7affd607749 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/AbstractBusinessObjectFactory.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/AbstractBusinessObjectFactory.java @@ -35,6 +35,11 @@ public abstract class AbstractBusinessObjectFactory { } + protected AbstractBusinessObjectFactory(final IDAOFactory daoFactory) + { + this.daoFactory = daoFactory; + } + protected final IDAOFactory getDaoFactory() { return daoFactory; diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/IGenericBusinessObjectFactory.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/ICommonBusinessObjectFactory.java similarity index 96% rename from openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/IGenericBusinessObjectFactory.java rename to openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/ICommonBusinessObjectFactory.java index b9f50a0bb59d763928dc8522a5a974e5b22ec98b..3ac6db43f94d87c7c1fbd438f7d7701722ff99c2 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/IGenericBusinessObjectFactory.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/ICommonBusinessObjectFactory.java @@ -23,7 +23,7 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.Session; * * @author Tomasz Pylak */ -public interface IGenericBusinessObjectFactory +public interface ICommonBusinessObjectFactory { public IGroupBO createGroupBO(final Session session); diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/ResourceNames.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/ResourceNames.java index 4b5445ad84f08d0c7674051f1f2704edb8701f75..a1012f552cfbaf7123fbb6949a9ea95eb65cbb3f 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/ResourceNames.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/ResourceNames.java @@ -34,6 +34,4 @@ public final class ResourceNames } public final static String COMMON_SERVICE = "common-service"; - - public final static String COMMON_SERVER = "common-server"; } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/AbstractClientService.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/AbstractClientService.java index b39590e34b278ed8d7cfdc3bf9d51d759d8f1417..b45c3a912f2adf3d417a6b1eb1d9fee41452b3cc 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/AbstractClientService.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/AbstractClientService.java @@ -21,7 +21,6 @@ import javax.servlet.http.HttpSession; import org.apache.log4j.Logger; -import ch.rinn.restrictions.Private; import ch.systemsx.cisd.common.exceptions.InvalidSessionException; import ch.systemsx.cisd.common.logging.LogCategory; import ch.systemsx.cisd.common.logging.LogFactory; @@ -52,11 +51,10 @@ public abstract class AbstractClientService implements IClientService @Resource(name = "request-context-provider") private IRequestContextProvider requestContextProvider; - public AbstractClientService() + protected AbstractClientService() { } - @Private protected AbstractClientService(final IRequestContextProvider requestContextProvider) { this.requestContextProvider = requestContextProvider; diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/AbstractPluginBusinessObjectFactory.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/AbstractPluginBusinessObjectFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..5d2cddf3f5e7f8e696d3e40c5abf48f34db51a62 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/AbstractPluginBusinessObjectFactory.java @@ -0,0 +1,44 @@ +/* + * 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.plugin; + +import javax.annotation.Resource; + +import ch.systemsx.cisd.openbis.generic.server.ComponentNames; +import ch.systemsx.cisd.openbis.generic.server.business.bo.AbstractBusinessObjectFactory; +import ch.systemsx.cisd.openbis.generic.server.business.bo.ICommonBusinessObjectFactory; + +/** + * An <i>abstract</i> {@link AbstractBusinessObjectFactory} extension which is able to delegate + * calls to the encapsulated {@link ICommonBusinessObjectFactory}. + * + * @author Christian Ribeaud + */ +public abstract class AbstractPluginBusinessObjectFactory extends AbstractBusinessObjectFactory +{ + @Resource(name = ComponentNames.COMMON_BUSINESS_OBJECT_FACTORY) + private ICommonBusinessObjectFactory commonBusinessObjectFactory; + + protected AbstractPluginBusinessObjectFactory() + { + } + + protected final ICommonBusinessObjectFactory getCommonBusinessObjectFactory() + { + return commonBusinessObjectFactory; + } +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/server/GenericClientService.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/server/GenericClientService.java index cfe23f04a72b68d90be1b9f90fdfae6fba0fd296..1a8544defa641864dc0166c34fbfb737f32565d7 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/server/GenericClientService.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/server/GenericClientService.java @@ -20,7 +20,6 @@ import javax.annotation.Resource; import org.springframework.stereotype.Component; -import ch.rinn.restrictions.Friend; import ch.rinn.restrictions.Private; import ch.systemsx.cisd.common.exceptions.UserFailureException; import ch.systemsx.cisd.common.servlet.IRequestContextProvider; @@ -45,7 +44,6 @@ import ch.systemsx.cisd.openbis.plugin.generic.shared.ResourceNames; * @author Franz-Josef Elmer */ @Component(value = ResourceNames.GENERIC_PLUGIN_SERVICE) -@Friend(toClasses = AbstractClientService.class) public final class GenericClientService extends AbstractClientService implements IGenericClientService { diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/server/GenericBusinessObjectFactory.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/server/GenericBusinessObjectFactory.java index 50bc2d0e0d6eb41f56df0168a2e53e213f531dae..1f8309cb63352703c6c80516fd4de8e020eef4ef 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/server/GenericBusinessObjectFactory.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/server/GenericBusinessObjectFactory.java @@ -18,70 +18,28 @@ package ch.systemsx.cisd.openbis.plugin.generic.server; import org.springframework.stereotype.Component; -import ch.systemsx.cisd.openbis.generic.server.business.bo.AbstractBusinessObjectFactory; -import ch.systemsx.cisd.openbis.generic.server.business.bo.EntityPropertiesConverter; -import ch.systemsx.cisd.openbis.generic.server.business.bo.ExternalDataTable; -import ch.systemsx.cisd.openbis.generic.server.business.bo.GroupBO; -import ch.systemsx.cisd.openbis.generic.server.business.bo.IEntityPropertiesConverter; -import ch.systemsx.cisd.openbis.generic.server.business.bo.IExternalDataTable; -import ch.systemsx.cisd.openbis.generic.server.business.bo.IGenericBusinessObjectFactory; -import ch.systemsx.cisd.openbis.generic.server.business.bo.IGroupBO; -import ch.systemsx.cisd.openbis.generic.server.business.bo.IRoleAssignmentTable; import ch.systemsx.cisd.openbis.generic.server.business.bo.ISampleBO; -import ch.systemsx.cisd.openbis.generic.server.business.bo.ISampleTable; -import ch.systemsx.cisd.openbis.generic.server.business.bo.RoleAssignmentTable; -import ch.systemsx.cisd.openbis.generic.server.business.bo.SampleBO; -import ch.systemsx.cisd.openbis.generic.server.business.bo.SampleTable; import ch.systemsx.cisd.openbis.generic.shared.dto.Session; -import ch.systemsx.cisd.openbis.generic.shared.dto.properties.EntityKind; +import ch.systemsx.cisd.openbis.plugin.AbstractPluginBusinessObjectFactory; import ch.systemsx.cisd.openbis.plugin.generic.shared.ResourceNames; /** * The unique {@link IGenericBusinessObjectFactory} implementation. * - * @author Tomasz Pylak + * @author Christian Ribeaud */ @Component(ResourceNames.GENERIC_BUSINESS_OBJECT_FACTORY) -public class GenericBusinessObjectFactory extends AbstractBusinessObjectFactory implements - IGenericBusinessObjectFactory +public final class GenericBusinessObjectFactory extends AbstractPluginBusinessObjectFactory + implements IGenericBusinessObjectFactory { - private GenericBusinessObjectFactory() - { - } // // IGenericBusinessObjectFactory // - public final IGroupBO createGroupBO(final Session session) - { - return new GroupBO(getDaoFactory(), session); - } - - public final IRoleAssignmentTable createRoleAssignmentTable(final Session session) - { - return new RoleAssignmentTable(getDaoFactory(), session); - } - - public final ISampleTable createSampleTable(final Session session) - { - return new SampleTable(getDaoFactory(), session); - } - public final ISampleBO createSampleBO(final Session session) { - final IEntityPropertiesConverter converter = - createEntityPropertiesConverter(EntityKind.SAMPLE); - return new SampleBO(getDaoFactory(), converter, session); - } - - public IEntityPropertiesConverter createEntityPropertiesConverter(final EntityKind entityKind) - { - return new EntityPropertiesConverter(entityKind, getDaoFactory()); + return getCommonBusinessObjectFactory().createSampleBO(session); } - public final IExternalDataTable createExternalDataTable(final Session session) - { - return new ExternalDataTable(getDaoFactory(), session); - } } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/server/GenericServer.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/server/GenericServer.java index c328c276dd66140d561d86e44d3c69956d77fb94..2d3803e7eae308b641705823d28692ce476310a5 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/server/GenericServer.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/server/GenericServer.java @@ -16,12 +16,14 @@ package ch.systemsx.cisd.openbis.plugin.generic.server; +import javax.annotation.Resource; + import org.springframework.stereotype.Component; +import ch.rinn.restrictions.Private; import ch.systemsx.cisd.authentication.ISessionManager; import ch.systemsx.cisd.common.utilities.ParameterChecker; import ch.systemsx.cisd.openbis.generic.server.AbstractServer; -import ch.systemsx.cisd.openbis.generic.server.business.bo.IGenericBusinessObjectFactory; import ch.systemsx.cisd.openbis.generic.server.business.bo.ISampleBO; import ch.systemsx.cisd.openbis.generic.server.dataaccess.IDAOFactory; import ch.systemsx.cisd.openbis.generic.shared.dto.SampleGenerationDTO; @@ -43,14 +45,19 @@ import ch.systemsx.cisd.openbis.plugin.generic.shared.ResourceNames; public final class GenericServer extends AbstractServer<IGenericServer> implements ch.systemsx.cisd.openbis.plugin.generic.shared.IGenericServer { + @Resource(name = ResourceNames.GENERIC_BUSINESS_OBJECT_FACTORY) + private IGenericBusinessObjectFactory businessObjectFactory; + public GenericServer() { } + @Private GenericServer(final ISessionManager<Session> sessionManager, final IDAOFactory daoFactory, - final IGenericBusinessObjectFactory boFactory) + final IGenericBusinessObjectFactory businessObjectFactory) { - super(sessionManager, daoFactory, boFactory); + super(sessionManager, daoFactory); + this.businessObjectFactory = businessObjectFactory; } // @@ -83,7 +90,7 @@ public final class GenericServer extends AbstractServer<IGenericServer> implemen final SampleIdentifier identifier) { final Session session = getSessionManager().getSession(sessionToken); - final ISampleBO sampleBO = getBusinessObjectFactory().createSampleBO(session); + final ISampleBO sampleBO = businessObjectFactory.createSampleBO(session); sampleBO.loadBySampleIdentifier(identifier); final SamplePE sample = sampleBO.getSample(); final ISampleServerPlugin plugin = @@ -95,7 +102,7 @@ public final class GenericServer extends AbstractServer<IGenericServer> implemen { final Session session = getSessionManager().getSession(sessionToken); ParameterChecker.checkIfNotNull(newSample, "sample"); - final ISampleBO sampleBO = getBusinessObjectFactory().createSampleBO(session); + final ISampleBO sampleBO = businessObjectFactory.createSampleBO(session); sampleBO.define(newSample); sampleBO.save(); } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/server/IGenericBusinessObjectFactory.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/server/IGenericBusinessObjectFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..b794f4613429f6709e3f47b45393aef03b24e53e --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/server/IGenericBusinessObjectFactory.java @@ -0,0 +1,34 @@ +/* + * 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.plugin.generic.server; + +import ch.systemsx.cisd.openbis.generic.server.business.bo.ISampleBO; +import ch.systemsx.cisd.openbis.generic.shared.dto.Session; + +/** + * A <i>generic</i> plugin specific business object factory. + * + * @author Christian Ribeaud + */ +public interface IGenericBusinessObjectFactory +{ + + /** + * Creates a {@link ISampleBO} <i>Business Object</i>. + */ + public ISampleBO createSampleBO(final Session session); +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/shared/ResourceNames.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/shared/ResourceNames.java index d631b45fbc8badcaeb77f7eb33ca076a0d0eb0a5..7a1696c52cdaa532dfc11e20ad5a1732058d534a 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/shared/ResourceNames.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/shared/ResourceNames.java @@ -32,11 +32,11 @@ public final class ResourceNames public final static String GENERIC_PLUGIN_SERVER = "generic-plugin-server"; + public final static String GENERIC_BUSINESS_OBJECT_FACTORY = "generic-business-object-factory"; + public final static String GENERIC_SAMPLE_TYPE_SLAVE_SERVER_PLUGIN = "generic-sample-type-slave-server-plugin"; - public final static String GENERIC_BUSINESS_OBJECT_FACTORY = "generic-business-object-factory"; - private ResourceNames() { // Can not be instantiated. diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/server/ScreeningClientService.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/server/ScreeningClientService.java index 7386446390d2a96bbbab058f70971d7cc682aafd..b3a43e94886c2d49a8f8bca22cc117f4847435c7 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/server/ScreeningClientService.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/server/ScreeningClientService.java @@ -20,6 +20,8 @@ import javax.annotation.Resource; import org.springframework.stereotype.Component; +import ch.rinn.restrictions.Private; +import ch.systemsx.cisd.common.servlet.IRequestContextProvider; import ch.systemsx.cisd.common.utilities.BeanUtils; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.SampleGeneration; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.SampleToRegister; @@ -49,6 +51,18 @@ public final class ScreeningClientService extends AbstractClientService implemen @Resource(name = ResourceNames.SCREENING_PLUGIN_SERVER) private IScreeningServer screeningServer; + public ScreeningClientService() + { + } + + @Private + ScreeningClientService(final IScreeningServer screeningServer, + final IRequestContextProvider requestContextProvider) + { + super(requestContextProvider); + this.screeningServer = screeningServer; + } + // // AbstractClientService // diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/IScreeningBusinessObjectFactory.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/IScreeningBusinessObjectFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..cd8998140dcf001a2a6ca92d06956b886a96402c --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/IScreeningBusinessObjectFactory.java @@ -0,0 +1,35 @@ +/* + * 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.plugin.screening.server; + +import ch.systemsx.cisd.openbis.generic.server.business.bo.ISampleBO; +import ch.systemsx.cisd.openbis.generic.shared.dto.Session; + +/** + * A <i>screening</i> plugin specific business object factory. + * + * @author Christian Ribeaud + */ +public interface IScreeningBusinessObjectFactory +{ + + /** + * Creates a {@link ISampleBO} <i>Business Object</i>. + */ + public ISampleBO createSampleBO(final Session session); + +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/ScreeningBusinessObjectFactory.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/ScreeningBusinessObjectFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..f913dcfa74f91a80d47f5d283ecea4800a917719 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/ScreeningBusinessObjectFactory.java @@ -0,0 +1,45 @@ +/* + * 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.plugin.screening.server; + +import org.springframework.stereotype.Component; + +import ch.systemsx.cisd.openbis.generic.server.business.bo.ISampleBO; +import ch.systemsx.cisd.openbis.generic.shared.dto.Session; +import ch.systemsx.cisd.openbis.plugin.AbstractPluginBusinessObjectFactory; +import ch.systemsx.cisd.openbis.plugin.screening.shared.ResourceNames; + +/** + * The unique {@link IScreeningBusinessObjectFactory} implementation. + * + * @author Christian Ribeaud + */ +@Component(ResourceNames.SCREENING_BUSINESS_OBJECT_FACTORY) +public final class ScreeningBusinessObjectFactory extends AbstractPluginBusinessObjectFactory + implements IScreeningBusinessObjectFactory +{ + + // + // IGenericBusinessObjectFactory + // + + public final ISampleBO createSampleBO(final Session session) + { + return getCommonBusinessObjectFactory().createSampleBO(session); + } + +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/ScreeningServer.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/ScreeningServer.java index c97f61ac4ef502d96ad06ce2c1d1c10c6aed1fc9..f4303a6db38d69e64340eac820b64104ecc895bd 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/ScreeningServer.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/ScreeningServer.java @@ -16,12 +16,14 @@ package ch.systemsx.cisd.openbis.plugin.screening.server; +import javax.annotation.Resource; + import org.springframework.stereotype.Component; +import ch.rinn.restrictions.Private; import ch.systemsx.cisd.authentication.ISessionManager; import ch.systemsx.cisd.common.exceptions.NotImplementedException; import ch.systemsx.cisd.openbis.generic.server.AbstractServer; -import ch.systemsx.cisd.openbis.generic.server.business.bo.IGenericBusinessObjectFactory; import ch.systemsx.cisd.openbis.generic.server.business.bo.ISampleBO; import ch.systemsx.cisd.openbis.generic.server.dataaccess.IDAOFactory; import ch.systemsx.cisd.openbis.generic.shared.dto.SampleGenerationDTO; @@ -43,14 +45,19 @@ import ch.systemsx.cisd.openbis.plugin.screening.shared.ResourceNames; public final class ScreeningServer extends AbstractServer<IScreeningServer> implements IScreeningServer { + @Resource(name = ResourceNames.SCREENING_BUSINESS_OBJECT_FACTORY) + private IScreeningBusinessObjectFactory businessObjectFactory; + public ScreeningServer() { } + @Private ScreeningServer(final ISessionManager<Session> sessionManager, final IDAOFactory daoFactory, - final IGenericBusinessObjectFactory businessObjectFactory) + final IScreeningBusinessObjectFactory businessObjectFactory) { - super(sessionManager, daoFactory, businessObjectFactory); + super(sessionManager, daoFactory); + this.businessObjectFactory = businessObjectFactory; } // @@ -83,7 +90,7 @@ public final class ScreeningServer extends AbstractServer<IScreeningServer> impl final SampleIdentifier identifier) { final Session session = getSessionManager().getSession(sessionToken); - final ISampleBO sampleBO = getBusinessObjectFactory().createSampleBO(session); + final ISampleBO sampleBO = businessObjectFactory.createSampleBO(session); sampleBO.loadBySampleIdentifier(identifier); final SamplePE sample = sampleBO.getSample(); final ISampleServerPlugin plugin = diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/screening/shared/ResourceNames.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/screening/shared/ResourceNames.java index de34d57bfa16e03fc3bd189c9a17bdc0e5d6c2c8..823585cbb949c6557e836837da167369cdbb621d 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/screening/shared/ResourceNames.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/screening/shared/ResourceNames.java @@ -37,6 +37,9 @@ public final class ResourceNames public final static String SCREENING_PLUGIN_SERVER = "screening-plugin-server"; + public final static String SCREENING_BUSINESS_OBJECT_FACTORY = + "screening-business-object-factory"; + public final static String MASTER_PLATE_SAMPLE_SERVER_PLUGIN = "master-plate-sample-server-plugin"; } diff --git a/openbis/source/java/genericApplicationContext.xml b/openbis/source/java/genericApplicationContext.xml index fccfe290eaf627a768091fc846180fdacbf5b2f0..2cca2a80a0a7d3ca37e29589a714914cefc523a3 100644 --- a/openbis/source/java/genericApplicationContext.xml +++ b/openbis/source/java/genericApplicationContext.xml @@ -61,6 +61,27 @@ <constructor-arg value="${session-timeout}" /> </bean> + <bean id="common-business-object-factory" + class="ch.systemsx.cisd.openbis.generic.server.CommonBusinessObjectFactory"> + <constructor-arg ref="dao-factory" /> + </bean> + + <!-- + // Common + --> + + <bean id="common-server" class="ch.systemsx.cisd.openbis.generic.server.CommonServer"> + <constructor-arg ref="authentication-service" /> + <constructor-arg ref="session-manager" /> + <constructor-arg ref="dao-factory" /> + <constructor-arg ref="common-business-object-factory" /> + </bean> + + <bean id="common-service" class="ch.systemsx.cisd.openbis.generic.client.web.server.CommonClientService"> + <constructor-arg ref="common-server" /> + <constructor-arg ref="request-context-provider" /> + </bean> + <!-- // Transaction --> @@ -106,7 +127,7 @@ <plugins:annotation-config /> - <plugins:component-scan base-package="ch.systemsx.cisd.openbis"> + <plugins:component-scan base-package="ch.systemsx.cisd.openbis.plugin"> <plugins:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller" /> </plugins:component-scan> diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/server/CommonClientServiceTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/server/CommonClientServiceTest.java index c09db61284c012bf449cadbf9e52f5afa168cbd8..b5e092d21599b189a275f3755de008c7cb1d1e1a 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/server/CommonClientServiceTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/server/CommonClientServiceTest.java @@ -30,7 +30,6 @@ import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import ch.rinn.restrictions.Friend; import ch.systemsx.cisd.common.servlet.IRequestContextProvider; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.DatabaseInstance; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.ListSampleCriteria; @@ -49,10 +48,8 @@ import ch.systemsx.cisd.openbis.plugin.generic.client.web.server.GenericClientSe * * @author Christian Ribeaud */ -@Friend(toClasses = CommonClientService.class) public final class CommonClientServiceTest { - private Mockery context; private ICommonServer commonServer; diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/CommonServerTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/CommonServerTest.java index 964b101440bdc5545945cef8a417d48eb67f9ff5..84e9a034b71292647cbda8ab04a8576d158d89ff 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/CommonServerTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/CommonServerTest.java @@ -45,7 +45,7 @@ public final class CommonServerTest extends AbstractServerTestCase private final ICommonServer createServer() { - return new CommonServer(authenticationService, sessionManager, daoFactory, boFactory); + return new CommonServer(authenticationService, sessionManager, daoFactory, commonBusinessObjectFactory); } private final static PersonPE createSystemUser() @@ -236,7 +236,7 @@ public final class CommonServerTest extends AbstractServerTestCase context.checking(new Expectations() { { - one(boFactory).createGroupBO(session); + one(commonBusinessObjectFactory).createGroupBO(session); will(returnValue(groupBO)); one(groupBO).define(groupCode, description, leader); @@ -382,7 +382,7 @@ public final class CommonServerTest extends AbstractServerTestCase context.checking(new Expectations() { { - one(boFactory).createExternalDataTable(session); + one(commonBusinessObjectFactory).createExternalDataTable(session); will(returnValue(externalDataTable)); one(externalDataTable).loadBySampleIdentifier(sampleIdentifier); diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/AbstractServerTestCase.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/AbstractServerTestCase.java index ccb02d6bb31b0338ef805bb5d230d4f1a99dbe8a..d6f6058f8114623804a259accb1b15ed0212495a 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/AbstractServerTestCase.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/AbstractServerTestCase.java @@ -25,8 +25,8 @@ import org.testng.annotations.BeforeMethod; import ch.systemsx.cisd.authentication.IAuthenticationService; import ch.systemsx.cisd.authentication.ISessionManager; import ch.systemsx.cisd.authentication.Principal; +import ch.systemsx.cisd.openbis.generic.server.business.bo.ICommonBusinessObjectFactory; import ch.systemsx.cisd.openbis.generic.server.business.bo.IExternalDataTable; -import ch.systemsx.cisd.openbis.generic.server.business.bo.IGenericBusinessObjectFactory; import ch.systemsx.cisd.openbis.generic.server.business.bo.IGroupBO; import ch.systemsx.cisd.openbis.generic.server.business.bo.ISampleBO; import ch.systemsx.cisd.openbis.generic.server.dataaccess.IDAOFactory; @@ -72,7 +72,7 @@ public abstract class AbstractServerTestCase extends AssertJUnit protected ISessionManager<Session> sessionManager; - protected IGenericBusinessObjectFactory boFactory; + protected ICommonBusinessObjectFactory commonBusinessObjectFactory; protected IDatabaseInstanceDAO databaseInstanceDAO; @@ -96,7 +96,7 @@ public abstract class AbstractServerTestCase extends AssertJUnit @BeforeMethod @SuppressWarnings("unchecked") - public final void setUp() + public void setUp() { context = new Mockery(); authenticationService = context.mock(IAuthenticationService.class); @@ -110,7 +110,7 @@ public abstract class AbstractServerTestCase extends AssertJUnit roleAssignmentDAO = context.mock(IRoleAssignmentDAO.class); externalDataDAO = context.mock(IExternalDataDAO.class); - boFactory = context.mock(IGenericBusinessObjectFactory.class); + commonBusinessObjectFactory = context.mock(ICommonBusinessObjectFactory.class); groupBO = context.mock(IGroupBO.class); sampleBO = context.mock(ISampleBO.class); externalDataTable = context.mock(IExternalDataTable.class); @@ -134,7 +134,7 @@ public abstract class AbstractServerTestCase extends AssertJUnit } @AfterMethod - public final void tearDown() + public void tearDown() { // To following line of code should also be called at the end of each test method. // Otherwise one do not known which test failed. diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/generic/server/GenericServerTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/generic/server/GenericServerTest.java index bd6d16975dafce1c805717a526e4fb9a4cf8d605..164f72d4e54cf0c3aa7d230d968d8222361c9910 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/generic/server/GenericServerTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/generic/server/GenericServerTest.java @@ -19,6 +19,7 @@ package ch.systemsx.cisd.openbis.plugin.generic.server; import org.jmock.Expectations; import org.testng.annotations.Test; +import ch.rinn.restrictions.Friend; import ch.systemsx.cisd.openbis.generic.shared.AbstractServerTestCase; import ch.systemsx.cisd.openbis.generic.shared.dto.SampleGenerationDTO; import ch.systemsx.cisd.openbis.generic.shared.dto.SamplePE; @@ -32,12 +33,25 @@ import ch.systemsx.cisd.openbis.plugin.generic.shared.IGenericServer; * * @author Franz-Josef Elmer */ +@Friend(toClasses = GenericServer.class) public final class GenericServerTest extends AbstractServerTestCase { + private IGenericBusinessObjectFactory genericBusinessObjectFactory; private final IGenericServer createServer() { - return new GenericServer(sessionManager, daoFactory, boFactory); + return new GenericServer(sessionManager, daoFactory, genericBusinessObjectFactory); + } + + // + // AbstractServerTestCase + // + + @Override + public final void setUp() + { + super.setUp(); + genericBusinessObjectFactory = context.mock(IGenericBusinessObjectFactory.class); } @Test @@ -49,7 +63,7 @@ public final class GenericServerTest extends AbstractServerTestCase context.checking(new Expectations() { { - one(boFactory).createSampleBO(session); + one(commonBusinessObjectFactory).createSampleBO(session); will(returnValue(sampleBO)); one(sampleBO).loadBySampleIdentifier(sampleIdentifier); @@ -80,7 +94,7 @@ public final class GenericServerTest extends AbstractServerTestCase context.checking(new Expectations() { { - one(boFactory).createSampleBO(session); + one(commonBusinessObjectFactory).createSampleBO(session); will(returnValue(sampleBO)); one(sampleBO).define(newSample); diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/screening/server/ScreeningServerTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/screening/server/ScreeningServerTest.java index 7a618a2481cfc6da7dea7767b078f5cc99a5bf7e..9c85684ce112f21cc4dc86fb99e5515cb05ba82f 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/screening/server/ScreeningServerTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/screening/server/ScreeningServerTest.java @@ -19,6 +19,7 @@ package ch.systemsx.cisd.openbis.plugin.screening.server; import org.jmock.Expectations; import org.testng.annotations.Test; +import ch.rinn.restrictions.Friend; import ch.systemsx.cisd.openbis.generic.shared.AbstractServerTestCase; import ch.systemsx.cisd.openbis.generic.shared.dto.SampleGenerationDTO; import ch.systemsx.cisd.openbis.generic.shared.dto.SamplePE; @@ -31,12 +32,25 @@ import ch.systemsx.cisd.openbis.plugin.screening.shared.IScreeningServer; * * @author Christian Ribeaud */ +@Friend(toClasses = ScreeningServer.class) public final class ScreeningServerTest extends AbstractServerTestCase { + private IScreeningBusinessObjectFactory screeningBusinessObjectFactory; private final IScreeningServer createServer() { - return new ScreeningServer(sessionManager, daoFactory, boFactory); + return new ScreeningServer(sessionManager, daoFactory, screeningBusinessObjectFactory); + } + + // + // AbstractServerTestCase + // + + @Override + public final void setUp() + { + super.setUp(); + screeningBusinessObjectFactory = context.mock(IScreeningBusinessObjectFactory.class); } @Test @@ -48,7 +62,7 @@ public final class ScreeningServerTest extends AbstractServerTestCase context.checking(new Expectations() { { - one(boFactory).createSampleBO(session); + one(commonBusinessObjectFactory).createSampleBO(session); will(returnValue(sampleBO)); one(sampleBO).loadBySampleIdentifier(sampleIdentifier);