diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/TrackingServer.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/TrackingServer.java index ce18b126ce6163a06d96e4f6e706ec135202afde..b1cd9b867fa5fad6822eeb6d944989157f50d057 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/TrackingServer.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/TrackingServer.java @@ -28,6 +28,8 @@ import ch.systemsx.cisd.openbis.generic.server.business.bo.datasetlister.IDatase import ch.systemsx.cisd.openbis.generic.server.business.bo.samplelister.ISampleLister; import ch.systemsx.cisd.openbis.generic.server.dataaccess.IDAOFactory; import ch.systemsx.cisd.openbis.generic.shared.ITrackingServer; +import ch.systemsx.cisd.openbis.generic.shared.basic.SearchlinkUtilities; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.EntityKind; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ExternalData; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ListOrSearchSampleCriteria; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample; @@ -75,7 +77,18 @@ public final class TrackingServer extends AbstractServer<ITrackingServer> implem final ISampleLister sampleLister = businessObjectFactory.createSampleLister(session); final ListOrSearchSampleCriteria listerCriteria = new ListOrSearchSampleCriteria(criteria); listerCriteria.setEnrichDependentSamplesWithProperties(true); - return sampleLister.list(listerCriteria); + List<Sample> result = sampleLister.list(listerCriteria); + fillSearchLinks(result, session.getBaseIndexURL()); + return result; + } + + private void fillSearchLinks(List<Sample> samples, String baseIndexURL) + { + for (Sample sample : samples) + { + sample.setPermlink(SearchlinkUtilities.createSearchlinkURL(baseIndexURL, + EntityKind.SAMPLE, sample.getCode())); + } } public List<ExternalData> listDataSets(String sessionToken, TrackingDataSetCriteria criteria) diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/samplelister/ISampleListingQuery.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/samplelister/ISampleListingQuery.java index 643c957bc8e2fb349423ba0b4d5680e198c85ac2..d66a5f1096a68f4831dfd0a8438b7ce5403ab238 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/samplelister/ISampleListingQuery.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/samplelister/ISampleListingQuery.java @@ -183,7 +183,7 @@ public interface ISampleListingQuery extends TransactionQuery, IPropertyListingQ */ @Select(sql = SELECT_FROM_SAMPLES_S + " join groups g on s.grou_id=g.id " + " where g.dbin_id=?{1} and s.saty_id=?{2} " - + " order by s.code", fetchSize = FETCH_SIZE) + + " order by s.code", fetchSize = FETCH_SIZE, rubberstamp = true) public DataIterator<SampleRecord> getAllGroupSamplesForSampleType(long dbInstanceId, long sampleTypeId); diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/samplelister/SampleListingWorker.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/samplelister/SampleListingWorker.java index aee5bafd96189c4694066436ae9ca1aaf9f1a395..2055dfcf46c9bf2014d7c31480dc9a2ccb7477fb 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/samplelister/SampleListingWorker.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/samplelister/SampleListingWorker.java @@ -41,7 +41,6 @@ import ch.systemsx.cisd.openbis.generic.server.business.bo.common.entity.Experim import ch.systemsx.cisd.openbis.generic.server.business.bo.common.entity.SecondaryEntityDAO; import ch.systemsx.cisd.openbis.generic.shared.basic.BasicConstant; import ch.systemsx.cisd.openbis.generic.shared.basic.PermlinkUtilities; -import ch.systemsx.cisd.openbis.generic.shared.basic.SearchlinkUtilities; import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DatabaseInstance; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.EntityKind; @@ -255,6 +254,17 @@ final class SampleListingWorker extends AbstractLister return sampleList; } + private static void log(StopWatch watch, String message) + { + if (operationLog.isDebugEnabled()) + { + watch.stop(); + operationLog.debug(String.format("%s took %s s", message, watch.toString())); + watch.reset(); + watch.start(); + } + } + // // Private worker methods // @@ -271,12 +281,7 @@ final class SampleListingWorker extends AbstractLister return sampleMap.get(id); } }); - if (operationLog.isDebugEnabled()) - { - watch.stop(); - operationLog.debug(String.format("Enrichment with properties took %s s", - watch.toString())); - } + log(watch, "Enrichment with properties"); } } @@ -511,7 +516,6 @@ final class SampleListingWorker extends AbstractLister private void retrievePrimaryBasicSamples(final Iterable<SampleRecord> sampleIteratorOrNull) { assert sampleList != null; - retrieveBasicSamples(sampleIteratorOrNull, sampleList); } @@ -528,6 +532,7 @@ final class SampleListingWorker extends AbstractLister return; } final boolean primarySample = (sampleListOrNull != null); + for (SampleRecord row : sampleIteratorOrNull) { final Sample sampleOrNull = tryCreateSample(row, primarySample); @@ -550,6 +555,7 @@ final class SampleListingWorker extends AbstractLister sample.setCode(IdentifierHelper.convertCode(row.code, null)); sample.setSubCode(IdentifierHelper.convertSubCode(row.code)); sample.setSampleType(sampleTypes.get(row.saty_id)); + // set group or instance if (row.grou_id == null) { @@ -581,8 +587,6 @@ final class SampleListingWorker extends AbstractLister sample.setProperties(new ArrayList<IEntityProperty>()); sample.setPermlink(PermlinkUtilities.createPermlinkURL(baseIndexURL, EntityKind.SAMPLE, row.perm_id)); - sample.setSearchlink(SearchlinkUtilities.createSearchlinkURL(baseIndexURL, - EntityKind.SAMPLE, row.code)); sample.setRegistrationDate(row.registration_timestamp); sample.setModificationDate(row.modification_timestamp); if (row.inva_id != null) diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/SearchlinkUtilities.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/SearchlinkUtilities.java index 294e542ee416f5577558b581f630ab4174967170..d4d18579bde387f4219813da847487bec463e96a 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/SearchlinkUtilities.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/SearchlinkUtilities.java @@ -31,14 +31,14 @@ public class SearchlinkUtilities public static final String SEARCH_ACTION = "SEARCH"; public final static String createSearchlinkURL(final String baseIndexURL, - final EntityKind entityKind, final String searchString) + final EntityKind entityKind, final String code) { URLMethodWithParameters ulrWithParameters = new URLMethodWithParameters(baseIndexURL); ulrWithParameters.startHistoryToken(); ulrWithParameters.addParameter(BasicConstant.LOCATOR_ACTION_PARAMETER, SEARCH_ACTION); - ulrWithParameters.addParameter(PermlinkUtilities.ENTITY_KIND_PARAMETER_KEY, entityKind - .name()); - ulrWithParameters.addParameter(CODE_PARAMETER_KEY, searchString); + ulrWithParameters.addParameter(PermlinkUtilities.ENTITY_KIND_PARAMETER_KEY, + entityKind.name()); + ulrWithParameters.addParameter(CODE_PARAMETER_KEY, code); return ulrWithParameters.toString(); } } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/Sample.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/Sample.java index 87657c2a147071d3c8d273a7775ead8ca63b9dfa..0206e2bbf4a6d75549734ea689ad60c5b4264bf1 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/Sample.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/Sample.java @@ -96,6 +96,8 @@ public final class Sample extends CodeWithRegistration<Sample> implements IInval this.permlink = permlink; } + // WORKAROUND for performance reasons search links are not filled in SampleLister + // (they are only used in TrackingServer they are filled just before samples are being returned) public String getSearchlink() { return searchlink;