diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/experiment/ISearchExperimentIdExecutor.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/experiment/ISearchExperimentIdExecutor.java new file mode 100644 index 0000000000000000000000000000000000000000..93f41f39a20107d2e99044a2db2ccac234e577ad --- /dev/null +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/experiment/ISearchExperimentIdExecutor.java @@ -0,0 +1,28 @@ +/* + * Copyright 2015 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.ethz.sis.openbis.generic.server.api.v3.executor.experiment; + +import ch.ethz.sis.openbis.generic.server.api.v3.executor.common.ISearchObjectExecutor; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.search.ExperimentSearchCriterion; + +/** + * @author pkupczyk + */ +public interface ISearchExperimentIdExecutor extends ISearchObjectExecutor<ExperimentSearchCriterion, Long> +{ + +} diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/experiment/SearchExperimentIdExecutor.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/experiment/SearchExperimentIdExecutor.java new file mode 100644 index 0000000000000000000000000000000000000000..42dad68e73b1fe079af1dbb5c5c9fe0ce836234f --- /dev/null +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/experiment/SearchExperimentIdExecutor.java @@ -0,0 +1,48 @@ +/* + * Copyright 2014 ETH Zuerich, Scientific IT Services + * + * 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.ethz.sis.openbis.generic.server.api.v3.executor.experiment; + +import java.util.List; + +import org.springframework.stereotype.Component; + +import ch.ethz.sis.openbis.generic.server.api.v3.executor.IOperationContext; +import ch.ethz.sis.openbis.generic.server.api.v3.executor.common.AbstractSearchObjectExecutor; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.search.ExperimentSearchCriterion; +import ch.systemsx.cisd.openbis.generic.server.business.search.ExperimentSearchManager; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DetailedSearchCriteria; + +/** + * @author pkupczyk + */ +@Component +public class SearchExperimentIdExecutor extends AbstractSearchObjectExecutor<ExperimentSearchCriterion, Long> implements + ISearchExperimentIdExecutor +{ + + @Override + protected List<Long> doSearch(IOperationContext context, DetailedSearchCriteria criteria) + { + ExperimentSearchManager searchManager = + new ExperimentSearchManager(daoFactory.getHibernateSearchDAO(), + businessObjectFactory.createExperimentTable(context.getSession())); + + return searchManager.searchForExperimentIDs(context.getSession().getUserName(), criteria); + + } + +} diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/method/MapExperimentMethodExecutor.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/method/MapExperimentMethodExecutor.java index 243bbedff58c8e1b9994040353e2534d647694f3..50c2c16f062c53911f592ae2568ad663702e1d5b 100644 --- a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/method/MapExperimentMethodExecutor.java +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/method/MapExperimentMethodExecutor.java @@ -17,7 +17,6 @@ package ch.ethz.sis.openbis.generic.server.api.v3.executor.method; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; import ch.ethz.sis.openbis.generic.server.api.v3.executor.common.IMapObjectByIdExecutor; import ch.ethz.sis.openbis.generic.server.api.v3.executor.experiment.IMapExperimentByIdExecutor; @@ -31,7 +30,7 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.ExperimentPE; /** * @author pkupczyk */ -@Component +// @Component public class MapExperimentMethodExecutor extends AbstractMapMethodExecutor<IExperimentId, ExperimentPE, Experiment, ExperimentFetchOptions> implements IMapExperimentMethodExecutor { diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/method/MapExperimentSqlMethodExecutor.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/method/MapExperimentSqlMethodExecutor.java new file mode 100644 index 0000000000000000000000000000000000000000..7ec9c93d5e0631fbf038bf66a10b28db6819e903 --- /dev/null +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/method/MapExperimentSqlMethodExecutor.java @@ -0,0 +1,78 @@ +/* + * Copyright 2015 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.ethz.sis.openbis.generic.server.api.v3.executor.method; + +import java.util.Collection; +import java.util.LinkedHashMap; +import java.util.Map; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import ch.ethz.sis.openbis.generic.server.api.v3.executor.IOperationContext; +import ch.ethz.sis.openbis.generic.server.api.v3.executor.common.IMapObjectByIdExecutor; +import ch.ethz.sis.openbis.generic.server.api.v3.executor.experiment.IMapExperimentByIdExecutor; +import ch.ethz.sis.openbis.generic.server.api.v3.translator.ITranslator; +import ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.experiment.sql.IExperimentSqlTranslator; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.experiment.Experiment; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.experiment.ExperimentFetchOptions; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.id.experiment.IExperimentId; +import ch.systemsx.cisd.openbis.generic.shared.dto.ExperimentPE; + +/** + * @author pkupczyk + */ +@Component +public class MapExperimentSqlMethodExecutor extends AbstractMapMethodExecutor<IExperimentId, Long, Experiment, ExperimentFetchOptions> + implements IMapExperimentMethodExecutor +{ + + @Autowired + private IMapExperimentByIdExecutor mapExecutor; + + @Autowired + private IExperimentSqlTranslator translator; + + @Override + protected IMapObjectByIdExecutor<IExperimentId, Long> getMapExecutor() + { + // TODO replace with IExperimentId -> Long mapExecutor once there is one + return new IMapObjectByIdExecutor<IExperimentId, Long>() + { + @Override + public Map<IExperimentId, Long> map(IOperationContext context, Collection<? extends IExperimentId> ids) + { + Map<IExperimentId, ExperimentPE> peMap = mapExecutor.map(context, ids); + Map<IExperimentId, Long> idMap = new LinkedHashMap<IExperimentId, Long>(); + + for (Map.Entry<IExperimentId, ExperimentPE> peEntry : peMap.entrySet()) + { + idMap.put(peEntry.getKey(), peEntry.getValue().getId()); + } + + return idMap; + } + }; + } + + @Override + protected ITranslator<Long, Experiment, ExperimentFetchOptions> getTranslator() + { + return translator; + } + +} diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/method/SearchExperimentMethodExecutor.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/method/SearchExperimentMethodExecutor.java index e9c2b95a38d033dc2a5e54bb5bf5dcdccebb4b46..988a33cd8630e9263ff0fcc04585736c127997c2 100644 --- a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/method/SearchExperimentMethodExecutor.java +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/method/SearchExperimentMethodExecutor.java @@ -17,7 +17,6 @@ package ch.ethz.sis.openbis.generic.server.api.v3.executor.method; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; import ch.ethz.sis.openbis.generic.server.api.v3.executor.common.ISearchObjectExecutor; import ch.ethz.sis.openbis.generic.server.api.v3.executor.experiment.ISearchExperimentExecutor; @@ -31,7 +30,7 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.ExperimentPE; /** * @author pkupczyk */ -@Component +// @Component public class SearchExperimentMethodExecutor extends AbstractSearchMethodExecutor<Experiment, ExperimentPE, ExperimentSearchCriterion, ExperimentFetchOptions> implements ISearchExperimentMethodExecutor diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/method/SearchExperimentSqlMethodExecutor.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/method/SearchExperimentSqlMethodExecutor.java new file mode 100644 index 0000000000000000000000000000000000000000..01c4d41f287b0d77018e0e5cb2035f273d92fcd1 --- /dev/null +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/method/SearchExperimentSqlMethodExecutor.java @@ -0,0 +1,57 @@ +/* + * Copyright 2015 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.ethz.sis.openbis.generic.server.api.v3.executor.method; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import ch.ethz.sis.openbis.generic.server.api.v3.executor.common.ISearchObjectExecutor; +import ch.ethz.sis.openbis.generic.server.api.v3.executor.experiment.ISearchExperimentIdExecutor; +import ch.ethz.sis.openbis.generic.server.api.v3.translator.ITranslator; +import ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.experiment.sql.IExperimentSqlTranslator; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.experiment.Experiment; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.experiment.ExperimentFetchOptions; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.search.ExperimentSearchCriterion; + +/** + * @author pkupczyk + */ +@Component +public class SearchExperimentSqlMethodExecutor extends + AbstractSearchMethodExecutor<Experiment, Long, ExperimentSearchCriterion, ExperimentFetchOptions> implements + ISearchExperimentMethodExecutor +{ + + @Autowired + private ISearchExperimentIdExecutor searchExecutor; + + @Autowired + private IExperimentSqlTranslator translator; + + @Override + protected ISearchObjectExecutor<ExperimentSearchCriterion, Long> getSearchExecutor() + { + return searchExecutor; + } + + @Override + protected ITranslator<Long, Experiment, ExperimentFetchOptions> getTranslator() + { + return translator; + } + +} diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/dataset/sql/IObjectToDataSetsSqlTranslator.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/dataset/sql/IObjectToDataSetsSqlTranslator.java new file mode 100644 index 0000000000000000000000000000000000000000..a3e0abe469a7bc28d683dfec33b3f274e5ffad7d --- /dev/null +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/dataset/sql/IObjectToDataSetsSqlTranslator.java @@ -0,0 +1,29 @@ +/* + * Copyright 2015 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.ethz.sis.openbis.generic.server.api.v3.translator.entity.dataset.sql; + +import ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.common.sql.IObjectToManyRelationTranslator; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.dataset.DataSet; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.dataset.DataSetFetchOptions; + +/** + * @author pkupczyk + */ +public interface IObjectToDataSetsSqlTranslator extends IObjectToManyRelationTranslator<DataSet, DataSetFetchOptions> +{ + +} diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/dataset/sql/ObjectToDataSetsSqlTranslator.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/dataset/sql/ObjectToDataSetsSqlTranslator.java new file mode 100644 index 0000000000000000000000000000000000000000..88467b2705ce71520dd64879ae9fc0c7f3164eb5 --- /dev/null +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/dataset/sql/ObjectToDataSetsSqlTranslator.java @@ -0,0 +1,68 @@ +/* + * Copyright 2015 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.ethz.sis.openbis.generic.server.api.v3.translator.entity.dataset.sql; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.springframework.beans.factory.annotation.Autowired; + +import ch.ethz.sis.openbis.generic.server.api.v3.translator.TranslationContext; +import ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.common.sql.ObjectToManyRelationTranslator; +import ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.dataset.IDataSetTranslator; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.dataset.DataSet; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.dataset.DataSetFetchOptions; +import ch.systemsx.cisd.openbis.generic.server.dataaccess.IDAOFactory; +import ch.systemsx.cisd.openbis.generic.shared.dto.DataPE; + +/** + * @author pkupczyk + */ +public abstract class ObjectToDataSetsSqlTranslator extends ObjectToManyRelationTranslator<DataSet, DataSetFetchOptions> implements + IObjectToDataSetsSqlTranslator +{ + + @Autowired + private IDAOFactory daoFactory; + + @Autowired + private IDataSetTranslator dataSetTranslator; + + @Override + protected Map<Long, DataSet> translateRelated(TranslationContext context, Collection<Long> relatedIds, DataSetFetchOptions relatedFetchOptions) + { + List<DataPE> related = daoFactory.getDataDAO().listByIDs(relatedIds); + Map<DataPE, DataSet> translated = dataSetTranslator.translate(context, related, relatedFetchOptions); + Map<Long, DataSet> result = new HashMap<Long, DataSet>(); + + for (Map.Entry<DataPE, DataSet> entry : translated.entrySet()) + { + result.put(entry.getKey().getId(), entry.getValue()); + } + return result; + } + + @Override + protected Collection<DataSet> createCollection() + { + return new ArrayList<DataSet>(); + } + +} diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/ExperimentAuthorizationRecord.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/ExperimentAuthorizationRecord.java new file mode 100644 index 0000000000000000000000000000000000000000..aa6213a6d12b77beeb922dedf26a34710b2f13f9 --- /dev/null +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/ExperimentAuthorizationRecord.java @@ -0,0 +1,33 @@ +/* + * Copyright 2015 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.ethz.sis.openbis.generic.server.api.v3.translator.entity.experiment.sql; + +/** + * @author pkupczyk + */ +public class ExperimentAuthorizationRecord +{ + + public Long id; + + public String code; + + public String projectCode; + + public String spaceCode; + +} diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/ExperimentAuthorizationSqlValidator.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/ExperimentAuthorizationSqlValidator.java new file mode 100644 index 0000000000000000000000000000000000000000..4aa5d45dee93bab6171f002ac95221b2b59c1cb4 --- /dev/null +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/ExperimentAuthorizationSqlValidator.java @@ -0,0 +1,69 @@ +/* + * Copyright 2015 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.ethz.sis.openbis.generic.server.api.v3.translator.entity.experiment.sql; + +import it.unimi.dsi.fastutil.longs.LongOpenHashSet; + +import java.util.Collection; +import java.util.LinkedList; +import java.util.List; + +import org.springframework.stereotype.Component; + +import net.lemnik.eodsql.QueryTool; + +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.id.experiment.ExperimentIdentifier; +import ch.systemsx.cisd.openbis.generic.server.authorization.validator.ExperimentByIdentiferValidator; +import ch.systemsx.cisd.openbis.generic.shared.basic.IIdentifierHolder; +import ch.systemsx.cisd.openbis.generic.shared.dto.PersonPE; + +/** + * @author pkupczyk + */ +@Component +public class ExperimentAuthorizationSqlValidator implements IExperimentAuthorizationSqlValidator +{ + + @Override + public Collection<Long> validate(PersonPE person, Collection<Long> experimentIds) + { + ExperimentQuery query = QueryTool.getManagedQuery(ExperimentQuery.class); + List<ExperimentAuthorizationRecord> records = query.getAuthorizations(new LongOpenHashSet(experimentIds)); + ExperimentByIdentiferValidator validator = new ExperimentByIdentiferValidator(); + List<Long> result = new LinkedList<Long>(); + + for (ExperimentAuthorizationRecord record : records) + { + final ExperimentAuthorizationRecord theRecord = record; + + if (validator.doValidation(person, new IIdentifierHolder() + { + @Override + public String getIdentifier() + { + return new ExperimentIdentifier(theRecord.spaceCode, theRecord.projectCode, theRecord.code).getIdentifier(); + } + })) + { + result.add(record.id); + } + } + + return result; + } + +} diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/ExperimentDataSetSqlTranslator.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/ExperimentDataSetSqlTranslator.java new file mode 100644 index 0000000000000000000000000000000000000000..3d31d700706cefb357f5f14a7409574afdf7fe02 --- /dev/null +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/ExperimentDataSetSqlTranslator.java @@ -0,0 +1,44 @@ +/* + * Copyright 2015 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.ethz.sis.openbis.generic.server.api.v3.translator.entity.experiment.sql; + +import it.unimi.dsi.fastutil.longs.LongOpenHashSet; + +import java.util.List; + +import net.lemnik.eodsql.QueryTool; + +import org.springframework.stereotype.Component; + +import ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.common.sql.ObjectRelationRecord; +import ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.dataset.sql.ObjectToDataSetsSqlTranslator; + +/** + * @author pkupczyk + */ +@Component +public class ExperimentDataSetSqlTranslator extends ObjectToDataSetsSqlTranslator implements IExperimentDataSetSqlTranslator +{ + + @Override + protected List<ObjectRelationRecord> loadRecords(LongOpenHashSet objectIds) + { + ExperimentQuery query = QueryTool.getManagedQuery(ExperimentQuery.class); + return query.getDataSetIds(objectIds); + } + +} diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/ExperimentMaterialPropertySqlTranslator.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/ExperimentMaterialPropertySqlTranslator.java new file mode 100644 index 0000000000000000000000000000000000000000..5f5653561741111638ab6b80841e28ec5cd272c1 --- /dev/null +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/ExperimentMaterialPropertySqlTranslator.java @@ -0,0 +1,45 @@ +/* + * Copyright 2015 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.ethz.sis.openbis.generic.server.api.v3.translator.entity.experiment.sql; + +import it.unimi.dsi.fastutil.longs.LongOpenHashSet; + +import java.util.Collection; +import java.util.List; + +import net.lemnik.eodsql.QueryTool; + +import org.springframework.stereotype.Component; + +import ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.property.sql.MaterialPropertyRecord; +import ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.property.sql.MaterialPropertySqlTranslator; + +/** + * @author pkupczyk + */ +@Component +public class ExperimentMaterialPropertySqlTranslator extends MaterialPropertySqlTranslator implements IExperimentMaterialPropertySqlTranslator +{ + + @Override + protected List<MaterialPropertyRecord> loadMaterialProperties(Collection<Long> objectIds) + { + ExperimentQuery query = QueryTool.getManagedQuery(ExperimentQuery.class); + return query.getMaterialProperties(new LongOpenHashSet(objectIds)); + } + +} diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/ExperimentModifierSqlTranslator.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/ExperimentModifierSqlTranslator.java new file mode 100644 index 0000000000000000000000000000000000000000..45e72a9af5e85e780b166e6a3cb65abc95b8d6a9 --- /dev/null +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/ExperimentModifierSqlTranslator.java @@ -0,0 +1,44 @@ +/* + * Copyright 2015 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.ethz.sis.openbis.generic.server.api.v3.translator.entity.experiment.sql; + +import it.unimi.dsi.fastutil.longs.LongOpenHashSet; + +import java.util.List; + +import net.lemnik.eodsql.QueryTool; + +import org.springframework.stereotype.Component; + +import ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.common.sql.ObjectRelationRecord; +import ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.person.sql.ObjectToPersonSqlTranslator; + +/** + * @author pkupczyk + */ +@Component +public class ExperimentModifierSqlTranslator extends ObjectToPersonSqlTranslator implements IExperimentModifierSqlTranslator +{ + + @Override + protected List<ObjectRelationRecord> loadRecords(LongOpenHashSet objectIds) + { + ExperimentQuery query = QueryTool.getManagedQuery(ExperimentQuery.class); + return query.getModifierIds(new LongOpenHashSet(objectIds)); + } + +} diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/ExperimentProjectSqlTranslator.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/ExperimentProjectSqlTranslator.java new file mode 100644 index 0000000000000000000000000000000000000000..7f48983c621840a4fdee65f4cb2b8d6b18c3eb38 --- /dev/null +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/ExperimentProjectSqlTranslator.java @@ -0,0 +1,44 @@ +/* + * Copyright 2015 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.ethz.sis.openbis.generic.server.api.v3.translator.entity.experiment.sql; + +import it.unimi.dsi.fastutil.longs.LongOpenHashSet; + +import java.util.List; + +import net.lemnik.eodsql.QueryTool; + +import org.springframework.stereotype.Component; + +import ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.common.sql.ObjectRelationRecord; +import ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.project.sql.ObjectToProjectSqlTranslator; + +/** + * @author pkupczyk + */ +@Component +public class ExperimentProjectSqlTranslator extends ObjectToProjectSqlTranslator implements IExperimentProjectSqlTranslator +{ + + @Override + protected List<ObjectRelationRecord> loadRecords(LongOpenHashSet objectIds) + { + ExperimentQuery query = QueryTool.getManagedQuery(ExperimentQuery.class); + return query.getProjectIds(new LongOpenHashSet(objectIds)); + } + +} diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/ExperimentPropertySqlTranslator.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/ExperimentPropertySqlTranslator.java new file mode 100644 index 0000000000000000000000000000000000000000..1810ab65ac0c1eb53afca02d7fd29417dc62aaef --- /dev/null +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/ExperimentPropertySqlTranslator.java @@ -0,0 +1,45 @@ +/* + * Copyright 2015 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.ethz.sis.openbis.generic.server.api.v3.translator.entity.experiment.sql; + +import it.unimi.dsi.fastutil.longs.LongOpenHashSet; + +import java.util.Collection; +import java.util.List; + +import net.lemnik.eodsql.QueryTool; + +import org.springframework.stereotype.Component; + +import ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.property.sql.PropertyRecord; +import ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.property.sql.PropertySqlTranslator; + +/** + * @author pkupczyk + */ +@Component +public class ExperimentPropertySqlTranslator extends PropertySqlTranslator implements IExperimentPropertySqlTranslator +{ + + @Override + protected List<PropertyRecord> loadProperties(Collection<Long> entityIds) + { + ExperimentQuery query = QueryTool.getManagedQuery(ExperimentQuery.class); + return query.getProperties(new LongOpenHashSet(entityIds)); + } + +} diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/ExperimentQuery.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/ExperimentQuery.java index 0b70f90ce1193c4607c44afc64c53fcc3561bdd7..2d32bddfa0a75e821a6e37a1ddeace071a130140 100644 --- a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/ExperimentQuery.java +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/ExperimentQuery.java @@ -25,6 +25,8 @@ import net.lemnik.eodsql.Select; import ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.common.sql.ObjectQuery; import ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.common.sql.ObjectRelationRecord; import ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.history.sql.HistoryPropertyRecord; +import ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.property.sql.MaterialPropertyRecord; +import ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.property.sql.PropertyRecord; import ch.systemsx.cisd.common.db.mapper.LongSetMapper; /** @@ -33,17 +35,58 @@ import ch.systemsx.cisd.common.db.mapper.LongSetMapper; public interface ExperimentQuery extends ObjectQuery { + @Select(sql = "select e.id, e.code, p.code as projectCode, sp.code as spaceCode " + + "from experiments e join projects p on e.proj_id = p.id " + + "join spaces sp on p.space_id = sp.id " + + "where e.id = any(?{1})", parameterBindings = { LongSetMapper.class }, fetchSize = FETCH_SIZE) + public List<ExperimentAuthorizationRecord> getAuthorizations(LongSet experimentIds); + @Select(sql = "select e.id, e.code, e.perm_id as permId, p.code as projectCode, sp.code as spaceCode, e.registration_timestamp as registrationDate, e.modification_timestamp as modificationDate " + "from experiments e join projects p on e.proj_id = p.id " + "join spaces sp on p.space_id = sp.id " + "where e.id = any(?{1})", parameterBindings = { LongSetMapper.class }, fetchSize = FETCH_SIZE) public List<ExperimentBaseRecord> getExperiments(LongSet experimentIds); - @Select(sql = "select eph.expe_id as entityId, eph.pers_id_author as authorId, pt.code as propertyCode, eph.value as propertyValue, eph.material as materialPropertyValue, eph.vocabulary_term as vocabularyPropertyValue, eph.valid_from_timestamp as validFrom, eph.valid_until_timestamp as validTo " - + "from experiment_properties_history eph " - + "left join experiment_type_property_types etpt on eph.etpt_id = etpt.id " + @Select(sql = "select e.id as objectId, e.exty_id as relatedId from experiments e where e.id = any(?{1})", parameterBindings = { LongSetMapper.class }, fetchSize = FETCH_SIZE) + public List<ObjectRelationRecord> getTypeIds(LongSet experimentIds); + + @Select(sql = "select et.id, et.code, et.description, et.modification_timestamp as modificationDate " + + "from experiment_types et where et.id = any(?{1})", parameterBindings = { LongSetMapper.class }, fetchSize = FETCH_SIZE) + public List<ExperimentTypeBaseRecord> getTypes(LongSet experimentTypeIds); + + @Select(sql = "select e.id as objectId, e.proj_id as relatedId from experiments e where e.id = any(?{1})", parameterBindings = { LongSetMapper.class }, fetchSize = FETCH_SIZE) + public List<ObjectRelationRecord> getProjectIds(LongSet experimentIds); + + @Select(sql = "select s.expe_id as objectId, s.id as relatedId from samples s where s.expe_id = any(?{1})", parameterBindings = { LongSetMapper.class }, fetchSize = FETCH_SIZE) + public List<ObjectRelationRecord> getSampleIds(LongSet experimentIds); + + @Select(sql = "select d.expe_id as objectId, d.id as relatedId from data d where d.expe_id = any(?{1})", parameterBindings = { LongSetMapper.class }, fetchSize = FETCH_SIZE) + public List<ObjectRelationRecord> getDataSetIds(LongSet experimentIds); + + // PropertyQueryGenerator was used to generate this query + @Select(sql = "select p.expe_id as entityId, pt.code as propertyCode, p.value as propertyValue, m.code as materialPropertyValueCode, mt.code as materialPropertyValueTypeCode, cvt.code as vocabularyPropertyValue " + + "from experiment_properties p " + + "left outer join materials m on p.mate_prop_id = m.id " + + "left outer join controlled_vocabulary_terms cvt on p.cvte_id = cvt.id " + + "left join material_types mt on m.maty_id = mt.id " + + "left join experiment_type_property_types etpt on p.etpt_id = etpt.id " + "left join property_types pt on etpt.prty_id = pt.id " - + "where eph.expe_id = any(?{1})", parameterBindings = { LongSetMapper.class }, fetchSize = FETCH_SIZE) + + "where p.expe_id = any(?{1})", parameterBindings = { LongSetMapper.class }, fetchSize = FETCH_SIZE) + public List<PropertyRecord> getProperties(LongSet experimentIds); + + // PropertyQueryGenerator was used to generate this query + @Select(sql = "select p.expe_id as entityId, pt.code as propertyCode, p.mate_prop_id as propertyValue " + + "from experiment_properties p " + + "left join experiment_type_property_types etpt on p.etpt_id = etpt.id " + + "left join property_types pt on etpt.prty_id = pt.id " + + "where p.mate_prop_id is not null and p.expe_id = any(?{1})", parameterBindings = { LongSetMapper.class }, fetchSize = FETCH_SIZE) + public List<MaterialPropertyRecord> getMaterialProperties(LongSet experimentIds); + + // PropertyQueryGenerator was used to generate this query + @Select(sql = "select ph.expe_id as entityId, ph.pers_id_author as authorId, pt.code as propertyCode, ph.value as propertyValue, ph.material as materialPropertyValue, ph.vocabulary_term as vocabularyPropertyValue, ph.valid_from_timestamp as validFrom, ph.valid_until_timestamp as validTo " + + "from experiment_properties_history ph " + + "left join experiment_type_property_types etpt on ph.etpt_id = etpt.id left join property_types pt on etpt.prty_id = pt.id " + + "where ph.expe_id = any(?{1})", parameterBindings = { LongSetMapper.class }, fetchSize = FETCH_SIZE) public List<HistoryPropertyRecord> getPropertiesHistory(LongSet experimentIds); @Select(sql = "select erh.main_expe_id as entityId, erh.pers_id_author as authorId, erh.relation_type as relationType, " @@ -52,7 +95,13 @@ public interface ExperimentQuery extends ObjectQuery + "from experiment_relationships_history erh where erh.valid_until_timestamp is not null and erh.main_expe_id = any(?{1})", parameterBindings = { LongSetMapper.class }, fetchSize = FETCH_SIZE) public List<ExperimentRelationshipRecord> getRelationshipsHistory(LongSet experimentIds); - @Select(sql = "select s.expe_id as objectId, s.id as relatedId from samples s where s.expe_id = any(?{1})", parameterBindings = { LongSetMapper.class }, fetchSize = FETCH_SIZE) - public List<ObjectRelationRecord> getSampleIds(LongSet experimentIds); + @Select(sql = "select e.id as objectId, e.pers_id_registerer as relatedId from experiments e where e.id = any(?{1})", parameterBindings = { LongSetMapper.class }, fetchSize = FETCH_SIZE) + public List<ObjectRelationRecord> getRegistratorIds(LongSet experimentIds); + + @Select(sql = "select e.id as objectId, e.pers_id_modifier as relatedId from experiments e where e.id = any(?{1})", parameterBindings = { LongSetMapper.class }, fetchSize = FETCH_SIZE) + public List<ObjectRelationRecord> getModifierIds(LongSet experimentIds); + + @Select(sql = "select ma.expe_id as objectId, ma.mepr_id as relatedId from metaproject_assignments ma where ma.expe_id = any(?{1})", parameterBindings = { LongSetMapper.class }, fetchSize = FETCH_SIZE) + public List<ObjectRelationRecord> getTagIds(LongSet experimentIds); } diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/ExperimentRegistratorSqlTranslator.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/ExperimentRegistratorSqlTranslator.java new file mode 100644 index 0000000000000000000000000000000000000000..b15d019da447dfc63ca4957a648340cb045c31e6 --- /dev/null +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/ExperimentRegistratorSqlTranslator.java @@ -0,0 +1,44 @@ +/* + * Copyright 2015 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.ethz.sis.openbis.generic.server.api.v3.translator.entity.experiment.sql; + +import it.unimi.dsi.fastutil.longs.LongOpenHashSet; + +import java.util.List; + +import net.lemnik.eodsql.QueryTool; + +import org.springframework.stereotype.Component; + +import ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.common.sql.ObjectRelationRecord; +import ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.person.sql.ObjectToPersonSqlTranslator; + +/** + * @author pkupczyk + */ +@Component +public class ExperimentRegistratorSqlTranslator extends ObjectToPersonSqlTranslator implements IExperimentRegistratorSqlTranslator +{ + + @Override + protected List<ObjectRelationRecord> loadRecords(LongOpenHashSet objectIds) + { + ExperimentQuery query = QueryTool.getManagedQuery(ExperimentQuery.class); + return query.getRegistratorIds(new LongOpenHashSet(objectIds)); + } + +} diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/ExperimentSqlTranslator.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/ExperimentSqlTranslator.java index f7e314253aa03142d37e0a66f83087d997ac0850..aaef19f2f3df378937ed9b2c2ea4475ed3d845d1 100644 --- a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/ExperimentSqlTranslator.java +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/ExperimentSqlTranslator.java @@ -17,13 +17,20 @@ package ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.experiment.sql; import java.util.Collection; +import java.util.List; +import java.util.Set; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; import ch.ethz.sis.openbis.generic.server.api.v3.translator.AbstractCachingTranslator; import ch.ethz.sis.openbis.generic.server.api.v3.translator.TranslationContext; import ch.ethz.sis.openbis.generic.server.api.v3.translator.TranslationResults; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.attachment.Attachment; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.dataset.DataSet; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.experiment.Experiment; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.sample.Sample; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.tag.Tag; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.experiment.ExperimentFetchOptions; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.id.experiment.ExperimentIdentifier; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.id.experiment.ExperimentPermId; @@ -31,6 +38,7 @@ import ch.ethz.sis.openbis.generic.shared.api.v3.dto.id.experiment.ExperimentPer /** * @author pkupczyk */ +@Component public class ExperimentSqlTranslator extends AbstractCachingTranslator<Long, Experiment, ExperimentFetchOptions> implements IExperimentSqlTranslator { @@ -40,6 +48,45 @@ public class ExperimentSqlTranslator extends AbstractCachingTranslator<Long, Exp @Autowired private IExperimentBaseSqlTranslator baseTranslator; + @Autowired + private IExperimentTypeRelationSqlTranslator typeTranslator; + + @Autowired + private IExperimentProjectSqlTranslator projectTranslator; + + @Autowired + private IExperimentSampleSqlTranslator sampleTranslator; + + @Autowired + private IExperimentDataSetSqlTranslator dataSetTranslator; + + @Autowired + private IExperimentPropertySqlTranslator propertyTranslator; + + @Autowired + private IExperimentMaterialPropertySqlTranslator materialPropertyTranslator; + + @Autowired + private IExperimentRegistratorSqlTranslator registratorTranslator; + + @Autowired + private IExperimentModifierSqlTranslator modifierTranslator; + + @Autowired + private IExperimentTagSqlTranslator tagTranslator; + + @Autowired + private IExperimentAttachmentSqlTranslator attachmentTranslator; + + @Autowired + private IExperimentHistorySqlTranslator historyTranslator; + + @Override + protected Collection<Long> shouldTranslate(TranslationContext context, Collection<Long> experimentIds, ExperimentFetchOptions fetchOptions) + { + return authorizationValidator.validate(context.getSession().tryGetPerson(), experimentIds); + } + @Override protected Experiment createObject(TranslationContext context, Long experimentId, ExperimentFetchOptions fetchOptions) { @@ -55,6 +102,66 @@ public class ExperimentSqlTranslator extends AbstractCachingTranslator<Long, Exp relations.put(IExperimentBaseSqlTranslator.class, baseTranslator.translate(context, experimentIds, null)); + if (fetchOptions.hasType()) + { + relations.put(IExperimentTypeRelationSqlTranslator.class, typeTranslator.translate(context, experimentIds, fetchOptions.withType())); + } + + if (fetchOptions.hasProject()) + { + relations.put(IExperimentProjectSqlTranslator.class, projectTranslator.translate(context, experimentIds, fetchOptions.withProject())); + } + + if (fetchOptions.hasSamples()) + { + relations.put(IExperimentSampleSqlTranslator.class, sampleTranslator.translate(context, experimentIds, fetchOptions.withSamples())); + } + + if (fetchOptions.hasDataSets()) + { + relations.put(IExperimentDataSetSqlTranslator.class, dataSetTranslator.translate(context, experimentIds, fetchOptions.withDataSets())); + } + + if (fetchOptions.hasProperties()) + { + relations.put(IExperimentPropertySqlTranslator.class, + propertyTranslator.translate(context, experimentIds, fetchOptions.withProperties())); + } + + if (fetchOptions.hasMaterialProperties()) + { + relations.put(IExperimentMaterialPropertySqlTranslator.class, + materialPropertyTranslator.translate(context, experimentIds, fetchOptions.withMaterialProperties())); + } + + if (fetchOptions.hasRegistrator()) + { + relations.put(IExperimentRegistratorSqlTranslator.class, + registratorTranslator.translate(context, experimentIds, fetchOptions.withRegistrator())); + } + + if (fetchOptions.hasModifier()) + { + relations.put(IExperimentModifierSqlTranslator.class, modifierTranslator.translate(context, experimentIds, fetchOptions.withModifier())); + } + + if (fetchOptions.hasTags()) + { + relations.put(IExperimentTagSqlTranslator.class, + tagTranslator.translate(context, experimentIds, fetchOptions.withTags())); + } + + if (fetchOptions.hasAttachments()) + { + relations.put(IExperimentAttachmentSqlTranslator.class, + attachmentTranslator.translate(context, experimentIds, fetchOptions.withAttachments())); + } + + if (fetchOptions.hasHistory()) + { + relations.put(IExperimentHistorySqlTranslator.class, historyTranslator.translate(context, experimentIds, fetchOptions.withHistory())); + } + return relations; } @@ -70,6 +177,72 @@ public class ExperimentSqlTranslator extends AbstractCachingTranslator<Long, Exp result.setIdentifier(new ExperimentIdentifier(baseRecord.spaceCode, baseRecord.projectCode, baseRecord.code)); result.setRegistrationDate(baseRecord.registrationDate); result.setModificationDate(baseRecord.modificationDate); + + if (fetchOptions.hasType()) + { + result.setType(relations.get(IExperimentTypeRelationSqlTranslator.class, experimentId)); + result.getFetchOptions().withTypeUsing(fetchOptions.withType()); + } + + if (fetchOptions.hasProject()) + { + result.setProject(relations.get(IExperimentProjectSqlTranslator.class, experimentId)); + result.getFetchOptions().withProjectUsing(fetchOptions.withProject()); + } + + if (fetchOptions.hasSamples()) + { + result.setSamples((List<Sample>) relations.get(IExperimentSampleSqlTranslator.class, experimentId)); + result.getFetchOptions().withSamplesUsing(fetchOptions.withSamples()); + } + + if (fetchOptions.hasDataSets()) + { + result.setDataSets((List<DataSet>) relations.get(IExperimentDataSetSqlTranslator.class, experimentId)); + result.getFetchOptions().withDataSetsUsing(fetchOptions.withDataSets()); + } + + if (fetchOptions.hasProperties()) + { + result.setProperties(relations.get(IExperimentPropertySqlTranslator.class, experimentId)); + result.getFetchOptions().withPropertiesUsing(fetchOptions.withProperties()); + } + + if (fetchOptions.hasMaterialProperties()) + { + result.setMaterialProperties(relations.get(IExperimentMaterialPropertySqlTranslator.class, experimentId)); + result.getFetchOptions().withMaterialPropertiesUsing(fetchOptions.withMaterialProperties()); + } + + if (fetchOptions.hasRegistrator()) + { + result.setRegistrator(relations.get(IExperimentRegistratorSqlTranslator.class, experimentId)); + result.getFetchOptions().withRegistratorUsing(fetchOptions.withRegistrator()); + } + + if (fetchOptions.hasModifier()) + { + result.setModifier(relations.get(IExperimentModifierSqlTranslator.class, experimentId)); + result.getFetchOptions().withModifierUsing(fetchOptions.withModifier()); + } + + if (fetchOptions.hasTags()) + { + result.setTags((Set<Tag>) relations.get(IExperimentTagSqlTranslator.class, experimentId)); + result.getFetchOptions().withTagsUsing(fetchOptions.withTags()); + } + + if (fetchOptions.hasAttachments()) + { + result.setAttachments((List<Attachment>) relations.get(IExperimentAttachmentSqlTranslator.class, experimentId)); + result.getFetchOptions().withAttachmentsUsing(fetchOptions.withAttachments()); + } + + if (fetchOptions.hasHistory()) + { + result.setHistory(relations.get(IExperimentHistorySqlTranslator.class, experimentId)); + result.getFetchOptions().withHistoryUsing(fetchOptions.withHistory()); + } } } diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/ExperimentTagSqlTranslator.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/ExperimentTagSqlTranslator.java new file mode 100644 index 0000000000000000000000000000000000000000..0a004254f3d6ea62520a30e00b6771ff4e4eb8e4 --- /dev/null +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/ExperimentTagSqlTranslator.java @@ -0,0 +1,44 @@ +/* + * Copyright 2015 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.ethz.sis.openbis.generic.server.api.v3.translator.entity.experiment.sql; + +import it.unimi.dsi.fastutil.longs.LongOpenHashSet; + +import java.util.List; + +import net.lemnik.eodsql.QueryTool; + +import org.springframework.stereotype.Component; + +import ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.common.sql.ObjectRelationRecord; +import ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.tag.sql.ObjectToTagsSqlTranslator; + +/** + * @author pkupczyk + */ +@Component +public class ExperimentTagSqlTranslator extends ObjectToTagsSqlTranslator implements IExperimentTagSqlTranslator +{ + + @Override + protected List<ObjectRelationRecord> loadRecords(LongOpenHashSet objectIds) + { + ExperimentQuery query = QueryTool.getManagedQuery(ExperimentQuery.class); + return query.getTagIds(objectIds); + } + +} diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/ExperimentTypeBaseRecord.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/ExperimentTypeBaseRecord.java new file mode 100644 index 0000000000000000000000000000000000000000..e4aaa69a493051b86be90284e9e16bbf57b36b35 --- /dev/null +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/ExperimentTypeBaseRecord.java @@ -0,0 +1,35 @@ +/* + * Copyright 2015 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.ethz.sis.openbis.generic.server.api.v3.translator.entity.experiment.sql; + +import java.util.Date; + +import ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.common.sql.ObjectBaseRecord; + +/** + * @author pkupczyk + */ +public class ExperimentTypeBaseRecord extends ObjectBaseRecord +{ + + public String code; + + public String description; + + public Date modificationDate; + +} diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/ExperimentTypeBaseSqlTranslator.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/ExperimentTypeBaseSqlTranslator.java new file mode 100644 index 0000000000000000000000000000000000000000..16d83f9cd079d9a17af91db1d5c6baaff18b60de --- /dev/null +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/ExperimentTypeBaseSqlTranslator.java @@ -0,0 +1,43 @@ +/* + * Copyright 2015 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.ethz.sis.openbis.generic.server.api.v3.translator.entity.experiment.sql; + +import it.unimi.dsi.fastutil.longs.LongOpenHashSet; + +import java.util.List; + +import org.springframework.stereotype.Component; + +import net.lemnik.eodsql.QueryTool; + +import ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.common.sql.ObjectBaseTranslator; + +/** + * @author pkupczyk + */ +@Component +public class ExperimentTypeBaseSqlTranslator extends ObjectBaseTranslator<ExperimentTypeBaseRecord> implements IExperimentTypeBaseSqlTranslator +{ + + @Override + protected List<ExperimentTypeBaseRecord> loadRecords(LongOpenHashSet objectIds) + { + ExperimentQuery query = QueryTool.getManagedQuery(ExperimentQuery.class); + return query.getTypes(objectIds); + } + +} diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/ExperimentTypeRelationSqlTranslator.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/ExperimentTypeRelationSqlTranslator.java new file mode 100644 index 0000000000000000000000000000000000000000..f368ce31dd498943c69945b38e4cd76748d0ab74 --- /dev/null +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/ExperimentTypeRelationSqlTranslator.java @@ -0,0 +1,61 @@ +/* + * Copyright 2015 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.ethz.sis.openbis.generic.server.api.v3.translator.entity.experiment.sql; + +import it.unimi.dsi.fastutil.longs.LongOpenHashSet; + +import java.util.Collection; +import java.util.List; +import java.util.Map; + +import net.lemnik.eodsql.QueryTool; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import ch.ethz.sis.openbis.generic.server.api.v3.translator.TranslationContext; +import ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.common.sql.ObjectRelationRecord; +import ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.common.sql.ObjectToOneRelationTranslator; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.experiment.ExperimentType; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.experiment.ExperimentTypeFetchOptions; + +/** + * @author pkupczyk + */ +@Component +public class ExperimentTypeRelationSqlTranslator extends ObjectToOneRelationTranslator<ExperimentType, ExperimentTypeFetchOptions> implements + IExperimentTypeRelationSqlTranslator +{ + + @Autowired + private IExperimentTypeSqlTranslator typeTranslator; + + @Override + protected List<ObjectRelationRecord> loadRecords(LongOpenHashSet objectIds) + { + ExperimentQuery query = QueryTool.getManagedQuery(ExperimentQuery.class); + return query.getTypeIds(objectIds); + } + + @Override + protected Map<Long, ExperimentType> translateRelated(TranslationContext context, Collection<Long> relatedIds, + ExperimentTypeFetchOptions relatedFetchOptions) + { + return typeTranslator.translate(context, relatedIds, relatedFetchOptions); + } + +} diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/ExperimentTypeSqlTranslator.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/ExperimentTypeSqlTranslator.java new file mode 100644 index 0000000000000000000000000000000000000000..ea3f883dea38d716ccf316f5e708b3b501fde833 --- /dev/null +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/ExperimentTypeSqlTranslator.java @@ -0,0 +1,73 @@ +/* + * Copyright 2015 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.ethz.sis.openbis.generic.server.api.v3.translator.entity.experiment.sql; + +import java.util.Collection; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import ch.ethz.sis.openbis.generic.server.api.v3.translator.AbstractCachingTranslator; +import ch.ethz.sis.openbis.generic.server.api.v3.translator.TranslationContext; +import ch.ethz.sis.openbis.generic.server.api.v3.translator.TranslationResults; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.experiment.ExperimentType; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.experiment.ExperimentTypeFetchOptions; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.id.entitytype.EntityTypePermId; + +/** + * @author pkupczyk + */ +@Component +public class ExperimentTypeSqlTranslator extends AbstractCachingTranslator<Long, ExperimentType, ExperimentTypeFetchOptions> implements + IExperimentTypeSqlTranslator +{ + + @Autowired + private IExperimentTypeBaseSqlTranslator baseTranslator; + + @Override + protected ExperimentType createObject(TranslationContext context, Long typeId, ExperimentTypeFetchOptions fetchOptions) + { + final ExperimentType type = new ExperimentType(); + type.setFetchOptions(new ExperimentTypeFetchOptions()); + return type; + } + + @Override + protected TranslationResults getObjectsRelations(TranslationContext context, Collection<Long> typeIds, ExperimentTypeFetchOptions fetchOptions) + { + TranslationResults relations = new TranslationResults(); + + relations.put(IExperimentTypeBaseSqlTranslator.class, baseTranslator.translate(context, typeIds, null)); + + return relations; + } + + @Override + protected void updateObject(TranslationContext context, Long typeId, ExperimentType result, Object objectRelations, + ExperimentTypeFetchOptions fetchOptions) + { + TranslationResults relations = (TranslationResults) objectRelations; + ExperimentTypeBaseRecord baseRecord = relations.get(IExperimentTypeBaseSqlTranslator.class, typeId); + + result.setPermId(new EntityTypePermId(baseRecord.code)); + result.setCode(baseRecord.code); + result.setDescription(baseRecord.description); + result.setModificationDate(baseRecord.modificationDate); + } + +} diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/IExperimentAuthorizationSqlValidator.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/IExperimentAuthorizationSqlValidator.java index 6602a4374bddc8a251dccbbbcdf88c335a68dac2..9528c0744ef8e008b02a7812e67db276d940900c 100644 --- a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/IExperimentAuthorizationSqlValidator.java +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/IExperimentAuthorizationSqlValidator.java @@ -16,10 +16,12 @@ package ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.experiment.sql; +import ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.common.sql.IObjectAuthorizationValidator; + /** * @author pkupczyk */ -public interface IExperimentAuthorizationSqlValidator +public interface IExperimentAuthorizationSqlValidator extends IObjectAuthorizationValidator { } diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/IExperimentDataSetSqlTranslator.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/IExperimentDataSetSqlTranslator.java new file mode 100644 index 0000000000000000000000000000000000000000..eb0d11f7b986f6871fe9605e4c40e3eff947f6c6 --- /dev/null +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/IExperimentDataSetSqlTranslator.java @@ -0,0 +1,27 @@ +/* + * Copyright 2015 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.ethz.sis.openbis.generic.server.api.v3.translator.entity.experiment.sql; + +import ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.dataset.sql.IObjectToDataSetsSqlTranslator; + +/** + * @author pkupczyk + */ +public interface IExperimentDataSetSqlTranslator extends IObjectToDataSetsSqlTranslator +{ + +} diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/IExperimentMaterialPropertySqlTranslator.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/IExperimentMaterialPropertySqlTranslator.java new file mode 100644 index 0000000000000000000000000000000000000000..5792dce65dbb192fe6fa6c68dba5b79157a91d64 --- /dev/null +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/IExperimentMaterialPropertySqlTranslator.java @@ -0,0 +1,27 @@ +/* + * Copyright 2015 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.ethz.sis.openbis.generic.server.api.v3.translator.entity.experiment.sql; + +import ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.property.sql.IMaterialPropertySqlTranslator; + +/** + * @author pkupczyk + */ +public interface IExperimentMaterialPropertySqlTranslator extends IMaterialPropertySqlTranslator +{ + +} diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/IExperimentModifierSqlTranslator.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/IExperimentModifierSqlTranslator.java new file mode 100644 index 0000000000000000000000000000000000000000..ddaefb55aa3b5aa54b1fdc083cb4c334dae92b28 --- /dev/null +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/IExperimentModifierSqlTranslator.java @@ -0,0 +1,27 @@ +/* + * Copyright 2015 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.ethz.sis.openbis.generic.server.api.v3.translator.entity.experiment.sql; + +import ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.person.sql.IObjectToPersonSqlTranslator; + +/** + * @author pkupczyk + */ +public interface IExperimentModifierSqlTranslator extends IObjectToPersonSqlTranslator +{ + +} diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/IExperimentProjectSqlTranslator.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/IExperimentProjectSqlTranslator.java new file mode 100644 index 0000000000000000000000000000000000000000..466fe56d17f0525e31780f12e779035e8d2134e8 --- /dev/null +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/IExperimentProjectSqlTranslator.java @@ -0,0 +1,27 @@ +/* + * Copyright 2015 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.ethz.sis.openbis.generic.server.api.v3.translator.entity.experiment.sql; + +import ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.project.sql.IObjectToProjectSqlTranslator; + +/** + * @author pkupczyk + */ +public interface IExperimentProjectSqlTranslator extends IObjectToProjectSqlTranslator +{ + +} diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/IExperimentPropertySqlTranslator.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/IExperimentPropertySqlTranslator.java new file mode 100644 index 0000000000000000000000000000000000000000..857233755f60b3d4e2b526a65f7fbbbf45864eb8 --- /dev/null +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/IExperimentPropertySqlTranslator.java @@ -0,0 +1,27 @@ +/* + * Copyright 2015 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.ethz.sis.openbis.generic.server.api.v3.translator.entity.experiment.sql; + +import ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.property.sql.IPropertySqlTranslator; + +/** + * @author pkupczyk + */ +public interface IExperimentPropertySqlTranslator extends IPropertySqlTranslator +{ + +} diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/IExperimentRegistratorSqlTranslator.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/IExperimentRegistratorSqlTranslator.java new file mode 100644 index 0000000000000000000000000000000000000000..96c46f2aac3281930b307421c71ceeb6522255f8 --- /dev/null +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/IExperimentRegistratorSqlTranslator.java @@ -0,0 +1,27 @@ +/* + * Copyright 2015 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.ethz.sis.openbis.generic.server.api.v3.translator.entity.experiment.sql; + +import ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.person.sql.IObjectToPersonSqlTranslator; + +/** + * @author pkupczyk + */ +public interface IExperimentRegistratorSqlTranslator extends IObjectToPersonSqlTranslator +{ + +} diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/IExperimentTagSqlTranslator.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/IExperimentTagSqlTranslator.java new file mode 100644 index 0000000000000000000000000000000000000000..1e4002d520fc2b33f4a53310474192158049009c --- /dev/null +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/IExperimentTagSqlTranslator.java @@ -0,0 +1,27 @@ +/* + * Copyright 2015 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.ethz.sis.openbis.generic.server.api.v3.translator.entity.experiment.sql; + +import ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.tag.sql.IObjectToTagsSqlTranslator; + +/** + * @author pkupczyk + */ +public interface IExperimentTagSqlTranslator extends IObjectToTagsSqlTranslator +{ + +} diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/IExperimentTypeBaseSqlTranslator.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/IExperimentTypeBaseSqlTranslator.java new file mode 100644 index 0000000000000000000000000000000000000000..2467b4a12f78861c4a0ddebaa69ad5c41c922783 --- /dev/null +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/IExperimentTypeBaseSqlTranslator.java @@ -0,0 +1,27 @@ +/* + * Copyright 2015 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.ethz.sis.openbis.generic.server.api.v3.translator.entity.experiment.sql; + +import ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.common.sql.IObjectBaseTranslator; + +/** + * @author pkupczyk + */ +public interface IExperimentTypeBaseSqlTranslator extends IObjectBaseTranslator<ExperimentTypeBaseRecord> +{ + +} diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/IExperimentTypeRelationSqlTranslator.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/IExperimentTypeRelationSqlTranslator.java new file mode 100644 index 0000000000000000000000000000000000000000..d7dd4bd8dbede08058f7b81a961055bba2a4c4ac --- /dev/null +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/IExperimentTypeRelationSqlTranslator.java @@ -0,0 +1,29 @@ +/* + * Copyright 2015 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.ethz.sis.openbis.generic.server.api.v3.translator.entity.experiment.sql; + +import ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.common.sql.IObjectToOneRelationTranslator; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.experiment.ExperimentType; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.experiment.ExperimentTypeFetchOptions; + +/** + * @author pkupczyk + */ +public interface IExperimentTypeRelationSqlTranslator extends IObjectToOneRelationTranslator<ExperimentType, ExperimentTypeFetchOptions> +{ + +} diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/IExperimentTypeSqlTranslator.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/IExperimentTypeSqlTranslator.java new file mode 100644 index 0000000000000000000000000000000000000000..174fceb707a704dd10e668b615cb133f9aa1dea2 --- /dev/null +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/experiment/sql/IExperimentTypeSqlTranslator.java @@ -0,0 +1,29 @@ +/* + * Copyright 2015 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.ethz.sis.openbis.generic.server.api.v3.translator.entity.experiment.sql; + +import ch.ethz.sis.openbis.generic.server.api.v3.translator.ITranslator; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.experiment.ExperimentType; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.experiment.ExperimentTypeFetchOptions; + +/** + * @author pkupczyk + */ +public interface IExperimentTypeSqlTranslator extends ITranslator<Long, ExperimentType, ExperimentTypeFetchOptions> +{ + +} diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/project/sql/IObjectToProjectSqlTranslator.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/project/sql/IObjectToProjectSqlTranslator.java new file mode 100644 index 0000000000000000000000000000000000000000..f8d50354f9f00d5a6fa968449c0cbb36a70caf8d --- /dev/null +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/project/sql/IObjectToProjectSqlTranslator.java @@ -0,0 +1,29 @@ +/* + * Copyright 2015 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.ethz.sis.openbis.generic.server.api.v3.translator.entity.project.sql; + +import ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.common.sql.IObjectToOneRelationTranslator; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.project.Project; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.project.ProjectFetchOptions; + +/** + * @author pkupczyk + */ +public interface IObjectToProjectSqlTranslator extends IObjectToOneRelationTranslator<Project, ProjectFetchOptions> +{ + +} diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/project/sql/ObjectToProjectSqlTranslator.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/project/sql/ObjectToProjectSqlTranslator.java new file mode 100644 index 0000000000000000000000000000000000000000..113049c02fdbf7e6dcb57a878f654cb9082cc5af --- /dev/null +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/project/sql/ObjectToProjectSqlTranslator.java @@ -0,0 +1,45 @@ +/* + * Copyright 2015 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.ethz.sis.openbis.generic.server.api.v3.translator.entity.project.sql; + +import java.util.Collection; +import java.util.Map; + +import org.springframework.beans.factory.annotation.Autowired; + +import ch.ethz.sis.openbis.generic.server.api.v3.translator.TranslationContext; +import ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.common.sql.ObjectToOneRelationTranslator; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.project.Project; +import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.project.ProjectFetchOptions; + +/** + * @author pkupczyk + */ +public abstract class ObjectToProjectSqlTranslator extends ObjectToOneRelationTranslator<Project, ProjectFetchOptions> implements + IObjectToProjectSqlTranslator +{ + + @Autowired + private IProjectSqlTranslator projectTranslator; + + @Override + protected Map<Long, Project> translateRelated(TranslationContext context, Collection<Long> relatedIds, ProjectFetchOptions relatedFetchOptions) + { + return projectTranslator.translate(context, relatedIds, relatedFetchOptions); + } + +} diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/property/sql/PropertyQueryGenerator.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/property/sql/PropertyQueryGenerator.java index 160e9b113e3b4dd31883e2ba4eca108c08f7e2af..a19f26988639208a935d347fef05a65c5a707caa 100644 --- a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/property/sql/PropertyQueryGenerator.java +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/property/sql/PropertyQueryGenerator.java @@ -24,12 +24,35 @@ public class PropertyQueryGenerator public static void main(String[] args) { + createExperimentPropertyQuery(); + createExperimentPropertyHistoryQuery(); createSamplePropertyQuery(); createSamplePropertyHistoryQuery(); createMaterialPropertyQuery(); createMaterialPropertyHistoryQuery(); } + private static void createExperimentPropertyQuery() + { + PropertyQueryParams params = new PropertyQueryParams(); + params.propertyTable = "experiment_properties"; + params.propertyTableEntityIdColumn = "expe_id"; + params.propertyTableEntityTypePropertyTypeIdColumn = "etpt_id"; + params.entityTypePropertyTypeTable = "experiment_type_property_types"; + System.out.println("Experiment property: \n" + createPropertyQuery(params)); + System.out.println("Experiment material property: \n" + createMaterialPropertyQuery(params)); + } + + private static void createExperimentPropertyHistoryQuery() + { + PropertyHistoryQueryParams params = new PropertyHistoryQueryParams(); + params.propertyHistoryTable = "experiment_properties_history"; + params.propertyHistoryTableEntityIdColumn = "expe_id"; + params.propertyHistoryTableEntityTypePropertyTypeIdColumn = "etpt_id"; + params.entityTypePropertyTypeTable = "experiment_type_property_types"; + System.out.println("Experiment property history: \n" + createPropertyHistoryQuery(params)); + } + private static void createSamplePropertyQuery() { PropertyQueryParams params = new PropertyQueryParams(); diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/sample/sql/ISampleDataSetSqlTranslator.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/sample/sql/ISampleDataSetSqlTranslator.java index 2f90f7fb6d1285abed31b3518b8e0acd09dd6ce7..ae5d801d381f7dbb69eddda260bd82bc092faa0c 100644 --- a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/sample/sql/ISampleDataSetSqlTranslator.java +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/sample/sql/ISampleDataSetSqlTranslator.java @@ -16,14 +16,12 @@ package ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.sample.sql; -import ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.common.sql.IObjectToManyRelationTranslator; -import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.dataset.DataSet; -import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.dataset.DataSetFetchOptions; +import ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.dataset.sql.IObjectToDataSetsSqlTranslator; /** * @author pkupczyk */ -public interface ISampleDataSetSqlTranslator extends IObjectToManyRelationTranslator<DataSet, DataSetFetchOptions> +public interface ISampleDataSetSqlTranslator extends IObjectToDataSetsSqlTranslator { } diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/sample/sql/SampleDataSetSqlTranslator.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/sample/sql/SampleDataSetSqlTranslator.java index 8983596046ff76f56c76da7b34ec20aae714111b..4d89055e908feb02a12ec369381191dd79e76c9e 100644 --- a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/sample/sql/SampleDataSetSqlTranslator.java +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/sample/sql/SampleDataSetSqlTranslator.java @@ -18,39 +18,22 @@ package ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.sample.sql; import it.unimi.dsi.fastutil.longs.LongOpenHashSet; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; import java.util.List; -import java.util.Map; import net.lemnik.eodsql.QueryTool; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import ch.ethz.sis.openbis.generic.server.api.v3.translator.TranslationContext; import ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.common.sql.ObjectRelationRecord; -import ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.common.sql.ObjectToManyRelationTranslator; -import ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.dataset.IDataSetTranslator; -import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.dataset.DataSet; -import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.dataset.DataSetFetchOptions; -import ch.systemsx.cisd.openbis.generic.server.dataaccess.IDAOFactory; -import ch.systemsx.cisd.openbis.generic.shared.dto.DataPE; +import ch.ethz.sis.openbis.generic.server.api.v3.translator.entity.dataset.sql.ObjectToDataSetsSqlTranslator; /** * @author pkupczyk */ @Component -public class SampleDataSetSqlTranslator extends ObjectToManyRelationTranslator<DataSet, DataSetFetchOptions> implements ISampleDataSetSqlTranslator +public class SampleDataSetSqlTranslator extends ObjectToDataSetsSqlTranslator implements ISampleDataSetSqlTranslator { - @Autowired - private IDAOFactory daoFactory; - - @Autowired - private IDataSetTranslator dataSetTranslator; - @Override protected List<ObjectRelationRecord> loadRecords(LongOpenHashSet objectIds) { @@ -58,24 +41,4 @@ public class SampleDataSetSqlTranslator extends ObjectToManyRelationTranslator<D return query.getDataSetIds(objectIds); } - @Override - protected Map<Long, DataSet> translateRelated(TranslationContext context, Collection<Long> relatedIds, DataSetFetchOptions relatedFetchOptions) - { - List<DataPE> related = daoFactory.getDataDAO().listByIDs(relatedIds); - Map<DataPE, DataSet> translated = dataSetTranslator.translate(context, related, relatedFetchOptions); - Map<Long, DataSet> result = new HashMap<Long, DataSet>(); - - for (Map.Entry<DataPE, DataSet> entry : translated.entrySet()) - { - result.put(entry.getKey().getId(), entry.getValue()); - } - return result; - } - - @Override - protected Collection<DataSet> createCollection() - { - return new ArrayList<DataSet>(); - } - -} +} \ No newline at end of file diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/sample/sql/SampleMaterialPropertySqlTranslator.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/sample/sql/SampleMaterialPropertySqlTranslator.java index 09e10f7f7e302e6421daae482ddce111f703bce9..ffa4cde88234a9ba84e1c04f8c15a705df9d07db 100644 --- a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/sample/sql/SampleMaterialPropertySqlTranslator.java +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/translator/entity/sample/sql/SampleMaterialPropertySqlTranslator.java @@ -40,7 +40,6 @@ public class SampleMaterialPropertySqlTranslator extends MaterialPropertySqlTran { SampleQuery query = QueryTool.getManagedQuery(SampleQuery.class); return query.getMaterialProperties(new LongOpenHashSet(objectIds)); - } }