diff --git a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/api/v1/FacadeFactory.java b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/api/v1/FacadeFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..302b053695844f404be0ccc66d9213d1b5ab4111 --- /dev/null +++ b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/api/v1/FacadeFactory.java @@ -0,0 +1,72 @@ +/* + * Copyright 2010 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.phosphonetx.client.api.v1; + +import ch.systemsx.cisd.common.spring.HttpInvokerUtils; +import ch.systemsx.cisd.openbis.generic.shared.DefaultLimsServiceStubFactory; +import ch.systemsx.cisd.openbis.generic.shared.OpenBisServiceFactory; +import ch.systemsx.cisd.openbis.plugin.phosphonetx.server.api.v1.Constants; +import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.api.v1.IRawDataService; + +/** + * Factory of {@link IRawDataApiFacade}. + * + * @author Franz-Josef Elmer + */ +public class FacadeFactory +{ + private static final int SERVER_TIMEOUT_MIN = 5; + + // Trick for discovering the server Url + private static String getServiceUrl(String serverUrl) + { + OpenBisServiceFactory openBisServiceFactory = + new OpenBisServiceFactory(serverUrl, new DefaultLimsServiceStubFactory()); + openBisServiceFactory.createService(); + return openBisServiceFactory.getUsedServerUrl() + Constants.RAW_DATA_SERVER_URL; + } + + /** + * Creates a facade for specified server URL, user Id, and password. + */ + public static IRawDataApiFacade create(String serverURL, String userID, String password) + { + String serviceUrl = getServiceUrl(serverURL); + IRawDataService service = + HttpInvokerUtils.createServiceStub(IRawDataService.class, serviceUrl, + SERVER_TIMEOUT_MIN); + String sessionToken = service.tryToAuthenticateAtRawDataServer(userID, password); + if (sessionToken == null) + { + throw new IllegalArgumentException("User " + userID + " couldn't be authenticated"); + } + return new RawDataApiFacade(service, sessionToken); + } + + /** + * Creates a facade for specified url and sessionToken. + */ + public static IRawDataApiFacade create(String serverURL, String sessionToken) + { + IRawDataService service = + HttpInvokerUtils.createServiceStub(IRawDataService.class, serverURL + + Constants.RAW_DATA_SERVER_URL, SERVER_TIMEOUT_MIN); + return new RawDataApiFacade(service, sessionToken); + } + + +} diff --git a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/api/v1/IRawDataApiFacade.java b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/api/v1/IRawDataApiFacade.java new file mode 100644 index 0000000000000000000000000000000000000000..99d733148d488908528c6318d91073193b4a5b3a --- /dev/null +++ b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/api/v1/IRawDataApiFacade.java @@ -0,0 +1,60 @@ +/* + * Copyright 2010 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.phosphonetx.client.api.v1; + +import java.util.List; + +import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.api.v1.dto.DataStoreServerProcessingPluginInfo; +import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.api.v1.dto.MsInjectionDataInfo; + + +/** + * Facade for openBIS PhosphoNetX raw data (aka MS_INJECTION data) service. + * + * @author Franz-Josef Elmer + */ +public interface IRawDataApiFacade +{ + /** + * Return the session token for the logged-in user. + */ + public String getSessionToken(); + + /** + * Returns all samples of type MS_INJECTION in space MS_DATA which have a parent sample which + * the specified user is allow to read. + */ + public List<MsInjectionDataInfo> listRawDataSamples(String userID); + + /** + * Lists all processing plugins on DSS. + */ + public List<DataStoreServerProcessingPluginInfo> listDataStoreServerProcessingPluginInfos(); + + /** + * Processes the data sets of specified samples by the DSS processing plug-in of specified key + * for the specified user. + */ + public void processingRawData(String userID, String dataSetProcessingKey, + long[] rawDataSampleIDs, String dataSetType); + + /** + * Logs current user out. + */ + public void logout(); + +} diff --git a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/api/v1/RawDataApiFacade.java b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/api/v1/RawDataApiFacade.java new file mode 100644 index 0000000000000000000000000000000000000000..4ef94ccef81c294c87d02647cfb501c2525d425c --- /dev/null +++ b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/api/v1/RawDataApiFacade.java @@ -0,0 +1,68 @@ +/* + * Copyright 2010 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.phosphonetx.client.api.v1; + +import java.util.List; + +import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.api.v1.IRawDataService; +import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.api.v1.dto.DataStoreServerProcessingPluginInfo; +import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.api.v1.dto.MsInjectionDataInfo; + +/** + * + * + * @author Franz-Josef Elmer + */ +class RawDataApiFacade implements IRawDataApiFacade +{ + private final IRawDataService service; + private final String sessionToken; + + RawDataApiFacade(IRawDataService service, String sessionToken) + { + this.service = service; + this.sessionToken = sessionToken; + } + + public String getSessionToken() + { + return sessionToken; + } + + public List<DataStoreServerProcessingPluginInfo> listDataStoreServerProcessingPluginInfos() + { + return service.listDataStoreServerProcessingPluginInfos(sessionToken); + } + + public List<MsInjectionDataInfo> listRawDataSamples(String userID) + { + return service.listRawDataSamples(sessionToken, userID); + } + + public void processingRawData(String userID, String dataSetProcessingKey, + long[] rawDataSampleIDs, String dataSetType) + { + service.processingRawData(sessionToken, userID, dataSetProcessingKey, rawDataSampleIDs, + dataSetType); + } + + public void logout() + { + service.logout(sessionToken); + } + +} diff --git a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/api/v1/RawDataApiTest.java b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/api/v1/RawDataApiTest.java new file mode 100644 index 0000000000000000000000000000000000000000..c456ae7f8fbde16781291840c61c477b80ef38d9 --- /dev/null +++ b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/api/v1/RawDataApiTest.java @@ -0,0 +1,69 @@ +/* + * Copyright 2010 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.phosphonetx.client.api.v1; + +import java.util.Date; +import java.util.List; +import java.util.Map; + +import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.api.v1.dto.DataStoreServerProcessingPluginInfo; +import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.api.v1.dto.MsInjectionDataInfo; + +/** + * + * + * @author Franz-Josef Elmer + */ +public class RawDataApiTest +{ + public static void main(String[] args) + { + if (args.length != 4) + { + System.err.println("Usage: <openbis-server-url> <login id> <password> <user id>"); + return; + } + + String serverURL = args[0]; + String loginID = args[1]; + String password = args[2]; + String userID = args[3]; + IRawDataApiFacade facade = FacadeFactory.create(serverURL, loginID, password); + + System.out.println("MS_INJECTION samples:"); + List<MsInjectionDataInfo> rawDataSamples = facade.listRawDataSamples(userID); + for (MsInjectionDataInfo info : rawDataSamples) + { + Map<String, Date> latestDataSets = info.getLatestDataSetRegistrationDates(); + if (latestDataSets.isEmpty() == false) + { + System.out.println(" " + info.getMsInjectionSampleCode() + " -> " + + info.getBiologicalSampleIdentifier() + ": latest data sets: " + + latestDataSets); + } + } + + System.out.println("DSS processing plugins:"); + List<DataStoreServerProcessingPluginInfo> infos = facade.listDataStoreServerProcessingPluginInfos(); + for (DataStoreServerProcessingPluginInfo info : infos) + { + System.out.println(" key:" + info.getKey() + ", label:'" + info.getLabel() + + "', data set types:" + info.getDatasetTypeCodes()); + } + facade.logout(); + } +} diff --git a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/server/PhosphoNetXClientService.java b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/server/PhosphoNetXClientService.java index 5281e1fe0ab9529d0b3135303b0fb3531d87a0ea..af71ac31a8d92c517a07d7ebb4caa671923924b3 100644 --- a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/server/PhosphoNetXClientService.java +++ b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/server/PhosphoNetXClientService.java @@ -43,8 +43,8 @@ import ch.systemsx.cisd.openbis.plugin.phosphonetx.client.web.client.dto.ListPro import ch.systemsx.cisd.openbis.plugin.phosphonetx.client.web.client.dto.ListProteinSummaryByExperimentCriteria; import ch.systemsx.cisd.openbis.plugin.phosphonetx.client.web.client.dto.ListSampleAbundanceByProteinCriteria; import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.IPhosphoNetXServer; +import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.IRawDataServiceInternal; import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.ResourceNames; -import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.api.v1.IRawDataServiceInternal; import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.basic.dto.AbundanceColumnDefinition; import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.basic.dto.AggregateFunction; import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.basic.dto.DataSetProtein; diff --git a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/server/RawDataSampleProvider.java b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/server/RawDataSampleProvider.java index 67129c0951447efad73a2ff5f5f902dd253d0df0..f8a58957e7f53853d8a5e3ac7a0f7fd9fe981ee1 100644 --- a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/server/RawDataSampleProvider.java +++ b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/server/RawDataSampleProvider.java @@ -30,7 +30,7 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.GenericTableRow; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.IEntityProperty; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ISerializableComparable; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample; -import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.api.v1.IRawDataServiceInternal; +import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.IRawDataServiceInternal; import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.dto.MsInjectionSample; /** diff --git a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/api/v1/Constants.java b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/api/v1/Constants.java new file mode 100644 index 0000000000000000000000000000000000000000..afc228880b9ed429f14ee1de82855086abbad536 --- /dev/null +++ b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/api/v1/Constants.java @@ -0,0 +1,30 @@ +/* + * Copyright 2010 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.phosphonetx.server.api.v1; + +/** + * + * + * @author Franz-Josef Elmer + */ +public class Constants +{ + public final static String RAW_DATA_SERVER_URL = "/rmi-phosphonetx-raw-data-v1"; + public final static String PHOSPHONETX_RAW_DATA_SERVICE = "phosphonetx-raw-data-service"; + public final static String PHOSPHONETX_RAW_DATA_SERVICE_INTERNAL = "phosphonetx-raw-data-service-internal"; + +} diff --git a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/api/v1/RawDataService.java b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/api/v1/RawDataService.java index 474519b9b20c9c81a89eb9fa1e59d6ce0d884af5..43f833667514668d70c7ea55538ba27d570fe2f5 100644 --- a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/api/v1/RawDataService.java +++ b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/api/v1/RawDataService.java @@ -16,9 +16,18 @@ package ch.systemsx.cisd.openbis.plugin.phosphonetx.server.api.v1; +import java.io.Serializable; import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Set; +import java.util.Map.Entry; + +import javax.annotation.Resource; + +import org.springframework.stereotype.Component; import ch.systemsx.cisd.authentication.ISessionManager; import ch.systemsx.cisd.common.exceptions.UserFailureException; @@ -26,24 +35,33 @@ import ch.systemsx.cisd.common.spring.IInvocationLoggerContext; import ch.systemsx.cisd.openbis.generic.server.AbstractServer; import ch.systemsx.cisd.openbis.generic.server.dataaccess.IDAOFactory; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataStoreServiceKind; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DatastoreServiceDescription; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataTypeCode; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ExternalData; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.IEntityProperty; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.PropertyType; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample; +import ch.systemsx.cisd.openbis.generic.shared.dto.DataSetTypePE; import ch.systemsx.cisd.openbis.generic.shared.dto.DataStorePE; import ch.systemsx.cisd.openbis.generic.shared.dto.DataStoreServicePE; import ch.systemsx.cisd.openbis.generic.shared.dto.Session; import ch.systemsx.cisd.openbis.generic.shared.dto.SessionContextDTO; -import ch.systemsx.cisd.openbis.generic.shared.translator.DataStoreServiceTranslator; +import ch.systemsx.cisd.openbis.generic.shared.util.DataTypeUtils; +import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.IRawDataServiceInternal; import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.api.v1.IRawDataService; -import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.api.v1.IRawDataServiceInternal; +import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.api.v1.dto.DataStoreServerProcessingPluginInfo; +import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.api.v1.dto.MsInjectionDataInfo; +import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.api.v1.dto.PropertyKey; import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.dto.MsInjectionSample; /** - * Imlementation of {@link IRawDataService}. + * Implementation of {@link IRawDataService}. * * @author Franz-Josef Elmer */ +@Component(Constants.PHOSPHONETX_RAW_DATA_SERVICE) public class RawDataService extends AbstractServer<IRawDataService> implements IRawDataService { + @Resource(name = Constants.PHOSPHONETX_RAW_DATA_SERVICE_INTERNAL) private IRawDataServiceInternal service; public RawDataService() @@ -57,22 +75,28 @@ public class RawDataService extends AbstractServer<IRawDataService> implements I this.service = service; } + public String tryToAuthenticateAtRawDataServer(String userID, String userPassword) + { + SessionContextDTO session = tryToAuthenticate(userID, userPassword); + return session == null ? null : session.getSessionToken(); + } + public IRawDataService createLogger(IInvocationLoggerContext context) { return new RawDataServiceLogger(getSessionManager(), context); } - public List<Sample> listRawDataSamples(String sessionToken, String userID) + public List<MsInjectionDataInfo> listRawDataSamples(String sessionToken, String userID) { checkSession(sessionToken); SessionContextDTO session = login(userID); try { List<MsInjectionSample> list = service.listRawDataSamples(session.getSessionToken()); - ArrayList<Sample> result = new ArrayList<Sample>(); + ArrayList<MsInjectionDataInfo> result = new ArrayList<MsInjectionDataInfo>(); for (MsInjectionSample sample : list) { - result.add(sample.getSample()); + result.add(translate(sample)); } return result; @@ -82,11 +106,46 @@ public class RawDataService extends AbstractServer<IRawDataService> implements I } } - public List<DatastoreServiceDescription> listDataStoreServices(String sessionToken) + private MsInjectionDataInfo translate(MsInjectionSample sample) + { + MsInjectionDataInfo info = new MsInjectionDataInfo(); + Sample msiSample = sample.getSample(); + info.setMsInjectionSampleID(msiSample.getId()); + info.setMsInjectionSampleCode(msiSample.getCode()); + info.setMsInjectionSampleRegistrationDate(msiSample.getRegistrationDate()); + info.setMsInjectionSampleProperties(translate(msiSample.getProperties())); + Sample bioSample = msiSample.getGeneratedFrom(); + info.setBiologicalSampleID(bioSample.getId()); + info.setBiologicalSampleIdentifier(bioSample.getIdentifier()); + info.setBiologicalSampleProperties(translate(bioSample.getProperties())); + Map<String, Date> latestDataSetRegistrationDates = new HashMap<String, Date>(); + for (Entry<String, ExternalData> entry : sample.getLatestDataSets().entrySet()) + { + latestDataSetRegistrationDates.put(entry.getKey(), entry.getValue().getRegistrationDate()); + } + info.setLatestDataSetRegistrationDates(latestDataSetRegistrationDates); + return info; + } + + private Map<PropertyKey, Serializable> translate(List<IEntityProperty> properties) + { + HashMap<PropertyKey, Serializable> map = new HashMap<PropertyKey, Serializable>(); + for (IEntityProperty property : properties) + { + PropertyType propertyType = property.getPropertyType(); + PropertyKey key = new PropertyKey(propertyType.getCode(), propertyType.getLabel()); + DataTypeCode dataTypeCode = propertyType.getDataType().getCode(); + map.put(key, DataTypeUtils.convertValueTo(dataTypeCode, property.tryGetAsString())); + } + return map; + } + + public List<DataStoreServerProcessingPluginInfo> listDataStoreServerProcessingPluginInfos( + String sessionToken) { checkSession(sessionToken); - List<DatastoreServiceDescription> result = new ArrayList<DatastoreServiceDescription>(); + List<DataStoreServerProcessingPluginInfo> result = new ArrayList<DataStoreServerProcessingPluginInfo>(); List<DataStorePE> dataStores = getDAOFactory().getDataStoreDAO().listDataStores(); for (DataStorePE dataStore : dataStores) { @@ -95,22 +154,35 @@ public class RawDataService extends AbstractServer<IRawDataService> implements I { if (dataStoreService.getKind() == DataStoreServiceKind.PROCESSING) { - result.add(DataStoreServiceTranslator.translate(dataStoreService)); + result.add(translate(dataStoreService)); } } } return result; } + private DataStoreServerProcessingPluginInfo translate(DataStoreServicePE dataStoreService) + { + String key = dataStoreService.getKey(); + String label = dataStoreService.getLabel(); + List<String> translatedCodes = new ArrayList<String>(); + Set<DataSetTypePE> datasetTypes = dataStoreService.getDatasetTypes(); + for (DataSetTypePE dataSetType : datasetTypes) + { + translatedCodes.add(dataSetType.getCode()); + } + return new DataStoreServerProcessingPluginInfo(key, label, translatedCodes); + } + public void processingRawData(String sessionToken, String userID, String dataSetProcessingKey, - long[] rawDataSampleIDs) + long[] rawDataSampleIDs, String dataSetType) { checkSession(sessionToken); SessionContextDTO session = login(userID); try { service.processRawData(session.getSessionToken(), dataSetProcessingKey, - rawDataSampleIDs, ""); + rawDataSampleIDs, dataSetType); } finally { service.logout(session.getSessionToken()); diff --git a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/api/v1/RawDataServiceInternal.java b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/api/v1/RawDataServiceInternal.java index 48d4b7a0f97bdf9943fba1e40e73f13204ca8e88..765b45f16c738d58eb9f442d9e796b3123ebd60e 100644 --- a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/api/v1/RawDataServiceInternal.java +++ b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/api/v1/RawDataServiceInternal.java @@ -45,7 +45,7 @@ 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.translator.SampleTypeTranslator; import ch.systemsx.cisd.openbis.plugin.phosphonetx.server.business.Manager; -import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.api.v1.IRawDataServiceInternal; +import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.IRawDataServiceInternal; import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.authorization.validator.RawDataSampleValidator; import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.dto.MsInjectionSample; diff --git a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/api/v1/RawDataServiceInternalLogger.java b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/api/v1/RawDataServiceInternalLogger.java index 23357a0e7e19c453679d3f69798a785c465a5ced..047e933592d2b359448732e252271786b915c4f9 100644 --- a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/api/v1/RawDataServiceInternalLogger.java +++ b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/api/v1/RawDataServiceInternalLogger.java @@ -22,7 +22,7 @@ import ch.systemsx.cisd.authentication.ISessionManager; import ch.systemsx.cisd.common.spring.IInvocationLoggerContext; import ch.systemsx.cisd.openbis.generic.server.AbstractServerLogger; import ch.systemsx.cisd.openbis.generic.shared.dto.Session; -import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.api.v1.IRawDataServiceInternal; +import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.IRawDataServiceInternal; import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.dto.MsInjectionSample; /** diff --git a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/api/v1/RawDataServiceLogger.java b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/api/v1/RawDataServiceLogger.java index 6674e8ebf007ea31a1dfd73af3e740c846b88bcd..98cf6922d7a460b95ae88081f3fcc9c5480cf132 100644 --- a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/api/v1/RawDataServiceLogger.java +++ b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/api/v1/RawDataServiceLogger.java @@ -21,10 +21,10 @@ import java.util.List; import ch.systemsx.cisd.authentication.ISessionManager; import ch.systemsx.cisd.common.spring.IInvocationLoggerContext; import ch.systemsx.cisd.openbis.generic.server.AbstractServerLogger; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DatastoreServiceDescription; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample; import ch.systemsx.cisd.openbis.generic.shared.dto.Session; import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.api.v1.IRawDataService; +import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.api.v1.dto.DataStoreServerProcessingPluginInfo; +import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.api.v1.dto.MsInjectionDataInfo; /** * @author Franz-Josef Elmer @@ -37,25 +37,31 @@ class RawDataServiceLogger extends AbstractServerLogger implements IRawDataServi super(sessionManager, context); } - public List<Sample> listRawDataSamples(String sessionToken, String userID) + public String tryToAuthenticateAtRawDataServer(String userID, String userPassword) + { + return null; + } + + public List<MsInjectionDataInfo> listRawDataSamples(String sessionToken, String userID) { logAccess(sessionToken, "list_raw_data_samples", "USER_ID(%s)", userID); return null; } - public List<DatastoreServiceDescription> listDataStoreServices(String sessionToken) + public List<DataStoreServerProcessingPluginInfo> listDataStoreServerProcessingPluginInfos( + String sessionToken) { logAccess(sessionToken, "list_data_store_services", ""); return null; } public void processingRawData(String sessionToken, String userID, String dataSetProcessingKey, - long[] rawDataSampleIDs) + long[] rawDataSampleIDs, String dataSetType) { int numberOfDataSets = rawDataSampleIDs == null ? 0 : rawDataSampleIDs.length; logAccess(sessionToken, "copy_raw_data", - "USER_ID(%s) DSS_PROCESSING_PLUGIN(%s) NUMBER_OF_DATA_SETS(%s)", userID, - dataSetProcessingKey, numberOfDataSets); + "USER_ID(%s) DSS_PROCESSING_PLUGIN(%s) NUMBER_OF_DATA_SETS(%s) DATA_SET_TYPE(%s)", + userID, dataSetProcessingKey, numberOfDataSets, dataSetType); } public int getMajorVersion() diff --git a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/api/v1/RawDataServiceServer.java b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/api/v1/RawDataServiceServer.java index a0a2d29992bf478a7065ef73a7a0e531ffc39806..d3a1eb303e91612fdb09e892278a70723874324d 100644 --- a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/api/v1/RawDataServiceServer.java +++ b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/api/v1/RawDataServiceServer.java @@ -25,7 +25,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import ch.systemsx.cisd.common.api.IRpcServiceNameServer; import ch.systemsx.cisd.common.api.RpcServiceInterfaceVersionDTO; import ch.systemsx.cisd.common.api.server.RpcServiceNameServer; -import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.ResourceNames; +import ch.systemsx.cisd.common.spring.ServiceExceptionTranslator; import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.api.v1.IRawDataService; /** @@ -35,10 +35,10 @@ import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.api.v1.IRawDataService */ @Controller @RequestMapping( - { "/rmi-phosphonetx-raw-data-v1", "/openbis/rmi-phosphonetx-raw-data-v1" }) + { Constants.RAW_DATA_SERVER_URL, "/openbis" + Constants.RAW_DATA_SERVER_URL }) public class RawDataServiceServer extends HttpInvokerServiceExporter { - @Resource(name = ResourceNames.PHOSPHONETX_RAW_DATA_SERVICE) + @Resource(name = Constants.PHOSPHONETX_RAW_DATA_SERVICE) private IRawDataService service; @Resource(name = IRpcServiceNameServer.PREFFERED_BEAN_NAME) @@ -49,9 +49,11 @@ public class RawDataServiceServer extends HttpInvokerServiceExporter { setServiceInterface(IRawDataService.class); setService(service); + setInterceptors(new Object[] + { new ServiceExceptionTranslator() }); RpcServiceInterfaceVersionDTO ifaceVersion = new RpcServiceInterfaceVersionDTO("phosphonetx-raw-data", - "/rmi-phosphonetx-raw-data-v1", 1, 0); + Constants.RAW_DATA_SERVER_URL, 1, 0); nameServer.addSupportedInterfaceVersion(ifaceVersion); super.afterPropertiesSet(); } diff --git a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/shared/api/v1/IRawDataServiceInternal.java b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/shared/IRawDataServiceInternal.java similarity index 96% rename from rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/shared/api/v1/IRawDataServiceInternal.java rename to rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/shared/IRawDataServiceInternal.java index e530b3934520522b122acca60ab3afac5850a214..72c86d06156111acd5c0ebfe19bc4a772710722b 100644 --- a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/shared/api/v1/IRawDataServiceInternal.java +++ b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/shared/IRawDataServiceInternal.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.api.v1; +package ch.systemsx.cisd.openbis.plugin.phosphonetx.shared; import java.util.List; diff --git a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/shared/ResourceNames.java b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/shared/ResourceNames.java index a0c44142b195e0f13b1728e6ff0118579a8f09c5..f33481e74974a58eb523fb89bbe2cb12dd0db3f2 100644 --- a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/shared/ResourceNames.java +++ b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/shared/ResourceNames.java @@ -31,8 +31,6 @@ public class ResourceNames public final static String PHOSPHONETX_PLUGIN_SERVER = "phosphonetx-plugin-server"; - public final static String PHOSPHONETX_RAW_DATA_SERVICE = "phosphonetx-raw-data-service"; - public final static String PHOSPHONETX_RAW_DATA_SERVICE_WEB = "phosphonetx-raw-data-service-web"; public final static String PHOSPHONETX_DAO_FACTORY = "phosphonetx-dao-factory"; diff --git a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/shared/api/v1/IRawDataService.java b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/shared/api/v1/IRawDataService.java index 62660fca22e7008aba6713302a63359504d1c12f..133dad42279b9d58c1c3985377a33033b0bfc9a2 100644 --- a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/shared/api/v1/IRawDataService.java +++ b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/shared/api/v1/IRawDataService.java @@ -21,34 +21,48 @@ import java.util.List; import org.springframework.transaction.annotation.Transactional; import ch.systemsx.cisd.common.api.IRpcService; -import ch.systemsx.cisd.openbis.generic.shared.IServer; import ch.systemsx.cisd.openbis.generic.shared.authorization.annotation.RoleSet; import ch.systemsx.cisd.openbis.generic.shared.authorization.annotation.RolesAllowed; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DatastoreServiceDescription; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample; +import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.api.v1.dto.DataStoreServerProcessingPluginInfo; +import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.api.v1.dto.MsInjectionDataInfo; /** * Service for querying raw data. * * @author Franz-Josef Elmer */ -public interface IRawDataService extends IServer, IRpcService +public interface IRawDataService extends IRpcService { + /** + * Tries to authenticate specified user with specified password. Returns session token if + * succeeded otherwise <code>null</code> is returned. + */ + @Transactional + // this is not a readOnly transaction - it can create new users + public String tryToAuthenticateAtRawDataServer(String userID, String userPassword); + + /** + * Logout the session with the specified session token. + */ + @Transactional(readOnly = true) + public void logout(String sessionToken); + /** * Returns all samples of type MS_INJECTION in space MS_DATA which have a parent sample which * the specified user is allow to read. */ @Transactional(readOnly = true) @RolesAllowed(RoleSet.INSTANCE_ADMIN_OBSERVER) - public List<Sample> listRawDataSamples(String sessionToken, String userID); + public List<MsInjectionDataInfo> listRawDataSamples(String sessionToken, String userID); /** - * Lists all processing DSS services. + * Lists all processing plugins on DSS. */ @Transactional(readOnly = true) @RolesAllowed(RoleSet.INSTANCE_ADMIN_OBSERVER) - public List<DatastoreServiceDescription> listDataStoreServices(String sessionToken); - + public List<DataStoreServerProcessingPluginInfo> listDataStoreServerProcessingPluginInfos( + String sessionToken); + /** * Processes the data sets of specified samples by the DSS processing plug-in of specified key * for the specified user. Implementations should check that the specified user is allowed to @@ -57,5 +71,5 @@ public interface IRawDataService extends IServer, IRpcService @Transactional(readOnly = true) @RolesAllowed(RoleSet.INSTANCE_ADMIN_OBSERVER) public void processingRawData(String sessionToken, String userID, String dataSetProcessingKey, - long[] rawDataSampleIDs); + long[] rawDataSampleIDs, String dataSetType); } diff --git a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/shared/api/v1/dto/DataStoreServerProcessingPluginInfo.java b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/shared/api/v1/dto/DataStoreServerProcessingPluginInfo.java new file mode 100644 index 0000000000000000000000000000000000000000..efac990c0182800fd028118243310e8b7d407191 --- /dev/null +++ b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/shared/api/v1/dto/DataStoreServerProcessingPluginInfo.java @@ -0,0 +1,70 @@ +/* + * Copyright 2010 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.phosphonetx.shared.api.v1.dto; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * Information about a processing plugin on a Data Store Server (DSS). + * + * @author Franz-Josef Elmer + */ +public class DataStoreServerProcessingPluginInfo implements Serializable +{ + + private static final long serialVersionUID = 1L; + private final String key; + private final String label; + private final List<String> datasetTypeCodes; + + /** + * Create a new instance for specified key, label and data set type codes. + */ + public DataStoreServerProcessingPluginInfo(String key, String label, List<String> datasetTypeCodes) + { + this.key = key; + this.label = label; + this.datasetTypeCodes = Collections.unmodifiableList(new ArrayList<String>(datasetTypeCodes)); + } + + /** + * Returns a unique key of the plugin. + */ + public String getKey() + { + return key; + } + + /** + * Returns a human readable name of the plugin. + */ + public String getLabel() + { + return label; + } + + /** + * Returns a list data set type codes for all data sets for which the plugin is available. + */ + public List<String> getDatasetTypeCodes() + { + return datasetTypeCodes; + } +} diff --git a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/shared/api/v1/dto/MsInjectionDataInfo.java b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/shared/api/v1/dto/MsInjectionDataInfo.java new file mode 100644 index 0000000000000000000000000000000000000000..912c6f56ace6833f798287cf8c865f2daff11f17 --- /dev/null +++ b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/shared/api/v1/dto/MsInjectionDataInfo.java @@ -0,0 +1,128 @@ +/* + * Copyright 2010 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.phosphonetx.shared.api.v1.dto; + +import java.io.Serializable; +import java.util.Date; +import java.util.Map; + +/** + * + * + * @author Franz-Josef Elmer + */ +public class MsInjectionDataInfo implements Serializable +{ + private static final long serialVersionUID = 1L; + + private long msInjectionSampleID; + + private String msInjectionSampleCode; + + private Date msInjectionSampleRegistrationDate; + + private Map<PropertyKey, Serializable> msInjectionSampleProperties; + + private long biologicalSampleID; + + private String biologicalSampleIdentifier; + + private Map<PropertyKey, Serializable> biologicalSampleProperties; + + private Map<String, Date> latestDataSetRegistrationDates; + + public long getMsInjectionSampleID() + { + return msInjectionSampleID; + } + + public void setMsInjectionSampleID(long msInjectionSampleID) + { + this.msInjectionSampleID = msInjectionSampleID; + } + + public String getMsInjectionSampleCode() + { + return msInjectionSampleCode; + } + + public void setMsInjectionSampleCode(String msInjectionSampleCode) + { + this.msInjectionSampleCode = msInjectionSampleCode; + } + + public Date getMsInjectionSampleRegistrationDate() + { + return msInjectionSampleRegistrationDate; + } + + public void setMsInjectionSampleRegistrationDate(Date msInjectionSampleRegistrationDate) + { + this.msInjectionSampleRegistrationDate = msInjectionSampleRegistrationDate; + } + + public Map<PropertyKey, Serializable> getMsInjectionSampleProperties() + { + return msInjectionSampleProperties; + } + + public void setMsInjectionSampleProperties( + Map<PropertyKey, Serializable> msInjectionSampleProperties) + { + this.msInjectionSampleProperties = msInjectionSampleProperties; + } + + public long getBiologicalSampleID() + { + return biologicalSampleID; + } + + public void setBiologicalSampleID(long biologicalSampleID) + { + this.biologicalSampleID = biologicalSampleID; + } + + public String getBiologicalSampleIdentifier() + { + return biologicalSampleIdentifier; + } + + public void setBiologicalSampleIdentifier(String biologicalSampleIdentifier) + { + this.biologicalSampleIdentifier = biologicalSampleIdentifier; + } + + public Map<PropertyKey, Serializable> getBiologicalSampleProperties() + { + return biologicalSampleProperties; + } + + public void setBiologicalSampleProperties(Map<PropertyKey, Serializable> biologicalSampleProperties) + { + this.biologicalSampleProperties = biologicalSampleProperties; + } + + public Map<String, Date> getLatestDataSetRegistrationDates() + { + return latestDataSetRegistrationDates; + } + + public void setLatestDataSetRegistrationDates(Map<String, Date> latestDataSetRegistrationDates) + { + this.latestDataSetRegistrationDates = latestDataSetRegistrationDates; + } +} diff --git a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/shared/api/v1/dto/PropertyKey.java b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/shared/api/v1/dto/PropertyKey.java new file mode 100644 index 0000000000000000000000000000000000000000..55ead925fe56ab16d86567be4f515ee39c20cbb4 --- /dev/null +++ b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/shared/api/v1/dto/PropertyKey.java @@ -0,0 +1,90 @@ +/* + * Copyright 2010 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.phosphonetx.shared.api.v1.dto; + +import java.io.Serializable; + +/** + * Immutable class of a property key. Two instances are equal if their IDs are equal. + * + * @author Franz-Josef Elmer + */ +public final class PropertyKey implements Serializable +{ + + private static final long serialVersionUID = 1L; + + private final String id; + + private final String label; + + /** + * Creates a new instance for specified ID and label. + */ + public PropertyKey(String id, String label) + { + this.id = id; + this.label = label; + } + + /** + * Returns the ID. + */ + public String getId() + { + return id; + } + + /** + * Returns the label. + */ + public String getLabel() + { + return label; + } + + @Override + public boolean equals(Object obj) + { + if (this == obj) + { + return true; + } + if (obj instanceof PropertyKey == false) + { + return false; + } + PropertyKey key = (PropertyKey) obj; + return key.id.equals(id); + } + + @Override + public int hashCode() + { + return id.hashCode(); + } + + /** + * Renders this key in the form <code><label>[<id>]</code>. + */ + @Override + public String toString() + { + return label + "[" + id + "]"; + } + +} diff --git a/rtd_phosphonetx/source/java/phosphonetx-applicationContext.xml b/rtd_phosphonetx/source/java/phosphonetx-applicationContext.xml index a466d08b7d928da47426e165122623dd60f0db4a..e79a58284e8cb7b2d4031401a11063571719a024 100644 --- a/rtd_phosphonetx/source/java/phosphonetx-applicationContext.xml +++ b/rtd_phosphonetx/source/java/phosphonetx-applicationContext.xml @@ -44,7 +44,7 @@ // Raw Data Server --> - <bean id="phosphonetx-raw-data-service" class="org.springframework.aop.framework.ProxyFactoryBean"> + <!--bean id="phosphonetx-raw-data-service" class="org.springframework.aop.framework.ProxyFactoryBean"> <property name="proxyInterfaces"> <list> <value>ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.api.v1.IRawDataService</value> @@ -62,7 +62,7 @@ <value>exception-translator</value> </list> </property> - </bean> + </bean--> <bean id="phosphonetx-raw-data-service-internal" class="ch.systemsx.cisd.openbis.plugin.phosphonetx.server.api.v1.RawDataServiceInternal" diff --git a/rtd_phosphonetx/source/java/service.properties b/rtd_phosphonetx/source/java/service.properties index 6881016234e9f4ea7ddd1d51d295a0d3da33d6dd..27d336408e81a1b2fbe783040c21bc9b17be110f 100644 --- a/rtd_phosphonetx/source/java/service.properties +++ b/rtd_phosphonetx/source/java/service.properties @@ -62,7 +62,17 @@ hibernate.search.index-mode = SKIP_IF_MARKER_FOUND hibernate.search.batch-size = 1000 -query-database.label = Protein Data -query-database.databaseEngineCode = ${phosphonetx.database.engine} -query-database.basicDatabaseName = phosphonetx -query-database.databaseKind = ${phosphonetx.database.kind} +# Database Configurations for Query module +query-databases = 1, 2 + +1.label = openBIS meta data +#1.data-space = CISD +#1.creator-minimal-role = SPACE_ADMIN +1.database-driver = org.postgresql.Driver +1.database-url = jdbc:postgresql://localhost/openbis_${database.kind} +#1.database-username = +#1.database-pasword = + +2.label = Protein Data +2.database-driver = org.postgresql.Driver +2.database-url = jdbc:postgresql://localhost/phosphonetx_${phosphonetx.database.kind} diff --git a/rtd_phosphonetx/sourceTest/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/RawDataTestClient.java b/rtd_phosphonetx/sourceTest/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/RawDataTestClient.java index f3e89ccbc7a0ea95989374f861338c514a1a298a..c3691ffd914f662d059062f13a6804c21000fe13 100644 --- a/rtd_phosphonetx/sourceTest/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/RawDataTestClient.java +++ b/rtd_phosphonetx/sourceTest/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/RawDataTestClient.java @@ -22,10 +22,9 @@ import ch.systemsx.cisd.common.exceptions.UserFailureException; import ch.systemsx.cisd.common.spring.HttpInvokerUtils; import ch.systemsx.cisd.openbis.generic.shared.DefaultLimsServiceStubFactory; import ch.systemsx.cisd.openbis.generic.shared.OpenBisServiceFactory; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DatastoreServiceDescription; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample; -import ch.systemsx.cisd.openbis.generic.shared.dto.SessionContextDTO; import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.api.v1.IRawDataService; +import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.api.v1.dto.DataStoreServerProcessingPluginInfo; +import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.api.v1.dto.MsInjectionDataInfo; /** * @author Franz-Josef Elmer @@ -57,20 +56,19 @@ public class RawDataTestClient try { System.out.println("User: " + user); - SessionContextDTO session = service.tryToAuthenticate("test", "a"); - String sessionToken = session.getSessionToken(); - List<DatastoreServiceDescription> services = - service.listDataStoreServices(sessionToken); - for (DatastoreServiceDescription datastoreServiceDescription : services) + String sessionToken = service.tryToAuthenticateAtRawDataServer("test", "a"); + List<DataStoreServerProcessingPluginInfo> services = + service.listDataStoreServerProcessingPluginInfos(sessionToken); + for (DataStoreServerProcessingPluginInfo info : services) { - System.out.print(datastoreServiceDescription.getLabel() + " "); + System.out.print(info.getLabel() + " "); } System.out.println(); - List<Sample> samples = service.listRawDataSamples(sessionToken, user); - for (Sample sample : samples) + List<MsInjectionDataInfo> samples = service.listRawDataSamples(sessionToken, user); + for (MsInjectionDataInfo sample : samples) { - System.out.println(" " + sample.getCode() + " -> " - + sample.getGeneratedFrom().getIdentifier()); + System.out.println(" " + sample.getMsInjectionSampleCode() + " -> " + + sample.getBiologicalSampleIdentifier()); } } catch (UserFailureException ex) { @@ -79,16 +77,15 @@ public class RawDataTestClient } System.out.println("--------------------"); - SessionContextDTO session = service.tryToAuthenticate("test_b", "t"); - String sessionToken = session.getSessionToken(); + String sessionToken = service.tryToAuthenticateAtRawDataServer("test_b", "t"); - List<Sample> samples = service.listRawDataSamples(sessionToken, "test_a"); + List<MsInjectionDataInfo> samples = service.listRawDataSamples(sessionToken, "test_a"); long[] ids = new long[samples.size()]; for (int i = 0; i < samples.size(); i++) { - Sample sample = samples.get(i); - ids[i] = sample.getId(); + MsInjectionDataInfo sample = samples.get(i); + ids[i] = sample.getMsInjectionSampleID(); } - service.processingRawData(sessionToken, "test_a", "copy-data-sets", ids); + service.processingRawData(sessionToken, "test_a", "copy-data-sets", ids, null); } } diff --git a/rtd_phosphonetx/sourceTest/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/server/RawDataSampleProviderTest.java b/rtd_phosphonetx/sourceTest/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/server/RawDataSampleProviderTest.java index cca65ff5a600f0cd514307eb422fa8c281a70782..816d9e7278cc963fc445162ba49a6bba5489c9d1 100644 --- a/rtd_phosphonetx/sourceTest/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/server/RawDataSampleProviderTest.java +++ b/rtd_phosphonetx/sourceTest/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/client/web/server/RawDataSampleProviderTest.java @@ -38,7 +38,7 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.GenericValueEntityPrope import ch.systemsx.cisd.openbis.generic.shared.basic.dto.IEntityProperty; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.PropertyType; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample; -import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.api.v1.IRawDataServiceInternal; +import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.IRawDataServiceInternal; import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.dto.MsInjectionSample; /** diff --git a/rtd_phosphonetx/sourceTest/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/RawDataServiceTest.java b/rtd_phosphonetx/sourceTest/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/RawDataServiceTest.java index 9b67cfc1fe815a2d39d4b34f1e69c2470ddeae5c..c80fdc3802b560e6eb2d7e6553e1780de287f692 100644 --- a/rtd_phosphonetx/sourceTest/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/RawDataServiceTest.java +++ b/rtd_phosphonetx/sourceTest/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/RawDataServiceTest.java @@ -16,8 +16,13 @@ package ch.systemsx.cisd.openbis.plugin.phosphonetx.server; +import java.io.Serializable; import java.util.Arrays; +import java.util.Collections; +import java.util.Date; +import java.util.HashSet; import java.util.List; +import java.util.Map; import org.jmock.Expectations; import org.testng.annotations.BeforeMethod; @@ -25,11 +30,25 @@ import org.testng.annotations.Test; import ch.systemsx.cisd.common.exceptions.UserFailureException; import ch.systemsx.cisd.openbis.generic.shared.AbstractServerTestCase; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetType; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataStoreServiceKind; +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.EntityProperty; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ExternalData; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.IEntityProperty; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.PropertyType; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample; +import ch.systemsx.cisd.openbis.generic.shared.dto.DataSetTypePE; +import ch.systemsx.cisd.openbis.generic.shared.dto.DataStorePE; +import ch.systemsx.cisd.openbis.generic.shared.dto.DataStoreServicePE; import ch.systemsx.cisd.openbis.generic.shared.dto.SessionContextDTO; import ch.systemsx.cisd.openbis.plugin.phosphonetx.server.api.v1.RawDataService; +import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.IRawDataServiceInternal; import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.api.v1.IRawDataService; -import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.api.v1.IRawDataServiceInternal; +import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.api.v1.dto.DataStoreServerProcessingPluginInfo; +import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.api.v1.dto.MsInjectionDataInfo; +import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.api.v1.dto.PropertyKey; import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.dto.MsInjectionSample; /** @@ -39,6 +58,9 @@ import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.dto.MsInjectionSample; */ public class RawDataServiceTest extends AbstractServerTestCase { + private static final String RAW_DATA = "RAW_DATA"; + private static final String MZXML_DATA = "MZXML_DATA"; + private IRawDataServiceInternal internalService; private IRawDataService service; private SessionContextDTO session2; @@ -54,12 +76,45 @@ public class RawDataServiceTest extends AbstractServerTestCase session2.setSessionToken(SESSION_TOKEN + "2"); } + @Test + public void testListDataStoreServerProcessingPluginInfos() + { + prepareGetSession(); + DataStoreServicePE s1 = new DataStoreServicePE(); + s1.setKind(DataStoreServiceKind.QUERIES); + DataStoreServicePE s2 = new DataStoreServicePE(); + s2.setKind(DataStoreServiceKind.PROCESSING); + s2.setKey("my-key"); + s2.setLabel("my label"); + DataSetTypePE dataSetType = new DataSetTypePE(); + dataSetType.setCode("my type"); + s2.setDatasetTypes(Collections.singleton(dataSetType)); + final DataStorePE store = new DataStorePE(); + store.setServices(new HashSet<DataStoreServicePE>(Arrays.asList(s1, s2))); + context.checking(new Expectations() + { + { + one(dataStoreDAO).listDataStores(); + will(returnValue(Arrays.asList(store))); + } + }); + + List<DataStoreServerProcessingPluginInfo> infos = + service.listDataStoreServerProcessingPluginInfos(SESSION_TOKEN); + + assertEquals(s2.getKey(), infos.get(0).getKey()); + assertEquals(s2.getLabel(), infos.get(0).getLabel()); + assertEquals(Arrays.asList(dataSetType.getCode()), infos.get(0).getDatasetTypeCodes()); + assertEquals(1, infos.size()); + context.assertIsSatisfied(); + } + @Test public void testListRawDataSamplesForUnknownUser() { prepareGetSession(); prepareLoginLogout(null); - + try { service.listRawDataSamples(SESSION_TOKEN, "abc"); @@ -78,18 +133,48 @@ public class RawDataServiceTest extends AbstractServerTestCase prepareGetSession(); prepareLoginLogout(session2); final Sample sample = new Sample(); + sample.setId(4711L); + sample.setCode("ms-inj-42"); + sample.setRegistrationDate(new Date(4711)); + IEntityProperty p1 = property("integer", DataTypeCode.INTEGER, "123456"); + IEntityProperty p2 = property("real", DataTypeCode.REAL, "1.25"); + IEntityProperty p3 = property("string", DataTypeCode.VARCHAR, "hello"); + sample.setProperties(Arrays.asList(p1, p2, p3)); + Sample parent = new Sample(); + parent.setId(4710L); + parent.setIdentifier("parent"); + IEntityProperty p4 = property("boolean", DataTypeCode.BOOLEAN, "true"); + IEntityProperty p5 = property("link", DataTypeCode.HYPERLINK, "link"); + parent.setProperties(Arrays.asList(p4, p5)); + sample .setGeneratedFrom(parent); context.checking(new Expectations() { { one(internalService).listRawDataSamples(session2.getSessionToken()); - will(returnValue(Arrays.asList(new MsInjectionSample(sample)))); + MsInjectionSample msInjectionSample = new MsInjectionSample(sample); + msInjectionSample.addLatestDataSet(createDataSet(RAW_DATA, 10)); + msInjectionSample.addLatestDataSet(createDataSet(MZXML_DATA, 20)); + msInjectionSample.addLatestDataSet(createDataSet(MZXML_DATA, 15)); + msInjectionSample.addLatestDataSet(createDataSet(RAW_DATA, 30)); + will(returnValue(Arrays.asList(msInjectionSample))); } }); - List<Sample> samples = service.listRawDataSamples(SESSION_TOKEN, "abc"); + List<MsInjectionDataInfo> infos = service.listRawDataSamples(SESSION_TOKEN, "abc"); - assertSame(sample, samples.get(0)); - assertEquals(1, samples.size()); + MsInjectionDataInfo info = infos.get(0); + assertEquals(sample.getId().longValue(), info.getMsInjectionSampleID()); + assertEquals(sample.getCode(), info.getMsInjectionSampleCode()); + assertEquals(sample.getRegistrationDate(), info.getMsInjectionSampleRegistrationDate()); + checkProperties(info.getMsInjectionSampleProperties(), p1, p2, p3); + assertEquals(parent.getId().longValue(), info.getBiologicalSampleID()); + assertEquals(parent.getIdentifier(), info.getBiologicalSampleIdentifier()); + checkProperties(info.getBiologicalSampleProperties(), p4, p5); + Map<String, Date> dates = info.getLatestDataSetRegistrationDates(); + assertEquals(30, dates.get(RAW_DATA).getTime()); + assertEquals(20, dates.get(MZXML_DATA).getTime()); + assertEquals(2, dates.size()); + assertEquals(1, infos.size()); context.assertIsSatisfied(); } @@ -101,7 +186,7 @@ public class RawDataServiceTest extends AbstractServerTestCase try { - service.processingRawData(SESSION_TOKEN, "abc", null, new long[0]); + service.processingRawData(SESSION_TOKEN, "abc", null, new long[0], null); fail("UserFailureException expected"); } catch (UserFailureException ex) { @@ -120,11 +205,11 @@ public class RawDataServiceTest extends AbstractServerTestCase context.checking(new Expectations() { { - one(internalService).processRawData(session2.getSessionToken(), null, ids, ""); + one(internalService).processRawData(session2.getSessionToken(), null, ids, "my-type"); } }); - service.processingRawData(SESSION_TOKEN, "abc", null, ids); + service.processingRawData(SESSION_TOKEN, "abc", null, ids, "my-type"); context.assertIsSatisfied(); } @@ -144,5 +229,38 @@ public class RawDataServiceTest extends AbstractServerTestCase } }); } + + private void checkProperties(Map<PropertyKey, Serializable> properties, IEntityProperty... expectedProperties) + { + for (IEntityProperty expectedProperty : expectedProperties) + { + PropertyType propertyType = expectedProperty.getPropertyType(); + PropertyKey key = new PropertyKey(propertyType.getCode(), propertyType.getLabel()); + Serializable v = properties.get(key); + assertNotNull("Missing property: " + key, v); + assertEquals("Property " + propertyType, expectedProperty.tryGetAsString(), String.valueOf(v)); + } + assertEquals(expectedProperties.length, properties.size()); + } + private IEntityProperty property(String code, DataTypeCode dataTypeCode, String value) + { + EntityProperty property = new EntityProperty(); + PropertyType propertyType = new PropertyType(); + propertyType.setCode(code.toUpperCase()); + propertyType.setLabel(code); + propertyType.setDataType(new DataType(dataTypeCode)); + property.setPropertyType(propertyType); + property.setValue(value); + return property; + } + + private ExternalData createDataSet(String type, long date) + { + ExternalData dataSet = new ExternalData(); + dataSet.setDataSetType(new DataSetType(type)); + dataSet.setRegistrationDate(new Date(date)); + return dataSet; + } + } diff --git a/rtd_phosphonetx/sourceTest/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/api/v1/RawDataServiceInternalTest.java b/rtd_phosphonetx/sourceTest/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/api/v1/RawDataServiceInternalTest.java index 492c65e3c2c17c67774b5f821a127728c8ca9138..989db34be68f6695e7c7b96589393665c44a52f9 100644 --- a/rtd_phosphonetx/sourceTest/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/api/v1/RawDataServiceInternalTest.java +++ b/rtd_phosphonetx/sourceTest/java/ch/systemsx/cisd/openbis/plugin/phosphonetx/server/api/v1/RawDataServiceInternalTest.java @@ -51,7 +51,7 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.DataStorePE; import ch.systemsx.cisd.openbis.generic.shared.dto.DataStoreServicePE; import ch.systemsx.cisd.openbis.generic.shared.dto.SampleTypePE; import ch.systemsx.cisd.openbis.plugin.phosphonetx.server.api.v1.RawDataServiceInternal; -import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.api.v1.IRawDataServiceInternal; +import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.IRawDataServiceInternal; import ch.systemsx.cisd.openbis.plugin.phosphonetx.shared.dto.MsInjectionSample; /**