Skip to content
Snippets Groups Projects
Commit d029c70d authored by buczekp's avatar buczekp
Browse files

[LMS-1229] fixed sample search with multiple db instances (2nd version)

SVN: 12954
parent 8703fb58
No related branches found
No related tags found
No related merge requests found
......@@ -65,7 +65,7 @@ public interface ISampleListingQuery extends TransactionQuery, IPropertyListingQ
/**
* Returns the sample for the given <var>sampleId</var>.
*/
@Select("select s.id, s.perm_id, s.code, s.expe_id, s.grou_id, "
@Select("select s.id, s.perm_id, s.code, s.expe_id, s.grou_id, s.dbin_id, "
+ " s.registration_timestamp, s.pers_id_registerer, "
+ " s.samp_id_generated_from, s.samp_id_part_of, s.saty_id, s.inva_id "
+ " from samples s where s.id=?{1}")
......@@ -74,7 +74,7 @@ public interface ISampleListingQuery extends TransactionQuery, IPropertyListingQ
/**
* Returns all samples in the database.
*/
@Select(sql = "select s.id, s.perm_id, s.code, s.expe_id, s.grou_id, "
@Select(sql = "select s.id, s.perm_id, s.code, s.expe_id, s.grou_id, s.dbin_id, "
+ " s.registration_timestamp, s.pers_id_registerer, "
+ " s.samp_id_generated_from, s.samp_id_part_of, s.saty_id, s.inva_id "
+ " from samples s left join groups g on s.grou_id=g.id where s.dbin_id=?{1} or g.dbin_id=?{1}", fetchSize = FETCH_SIZE)
......@@ -87,7 +87,7 @@ public interface ISampleListingQuery extends TransactionQuery, IPropertyListingQ
/**
* Returns the samples for the given <var>groupCode</var>.
*/
@Select(sql = "select s.id, s.perm_id, s.code, s.expe_id, s.grou_id, "
@Select(sql = "select s.id, s.perm_id, s.code, s.expe_id, s.grou_id, s.dbin_id, "
+ " s.registration_timestamp, s.pers_id_registerer, "
+ " s.samp_id_generated_from, s.samp_id_part_of, s.saty_id, s.inva_id "
+ " from samples s join sample_types st on s.saty_id=st.id"
......@@ -98,7 +98,7 @@ public interface ISampleListingQuery extends TransactionQuery, IPropertyListingQ
/**
* Returns the samples for the given <var>groupCode</var> that are assigned to an experiment.
*/
@Select(sql = "select s.id, s.perm_id, s.code, s.saty_id, s.expe_id, s.grou_id, "
@Select(sql = "select s.id, s.perm_id, s.code, s.saty_id, s.expe_id, s.grou_id, s.dbin_id, "
+ " s.samp_id_generated_from, s.registration_timestamp, s.modification_timestamp, "
+ " s.pers_id_registerer, s.samp_id_part_of, s.inva_id "
+ " from samples s join groups g on s.grou_id=g.id "
......@@ -110,7 +110,7 @@ public interface ISampleListingQuery extends TransactionQuery, IPropertyListingQ
/**
* Returns the samples for the given <var>groupCode</var> and <var>sampleTypeId</var>
*/
@Select(sql = "select s.id, s.perm_id, s.code, s.expe_id, s.grou_id, "
@Select(sql = "select s.id, s.perm_id, s.code, s.expe_id, s.grou_id, s.dbin_id, "
+ " s.registration_timestamp, s.pers_id_registerer, "
+ " s.samp_id_generated_from, s.samp_id_part_of, s.saty_id, s.inva_id "
+ " from samples s join groups g on s.grou_id=g.id "
......@@ -123,7 +123,7 @@ public interface ISampleListingQuery extends TransactionQuery, IPropertyListingQ
* Returns the samples for the given <var>groupCode</var> and <var>sampleTypeId</var> that are
* assigned to an experiment.
*/
@Select(sql = "select s.id, s.perm_id, s.code, s.saty_id, s.expe_id, s.grou_id, "
@Select(sql = "select s.id, s.perm_id, s.code, s.saty_id, s.expe_id, s.grou_id, s.dbin_id, "
+ " s.samp_id_generated_from, s.registration_timestamp, s.modification_timestamp, "
+ " s.pers_id_registerer, s.samp_id_part_of, s.inva_id "
+ " from samples s join groups g on s.grou_id=g.id "
......@@ -139,7 +139,7 @@ public interface ISampleListingQuery extends TransactionQuery, IPropertyListingQ
/**
* Returns the samples for the given <var>experimentId</var>.
*/
@Select(sql = "select s.id, s.perm_id, s.code, s.expe_id, s.grou_id, "
@Select(sql = "select s.id, s.perm_id, s.code, s.expe_id, s.grou_id, s.dbin_id, "
+ " s.registration_timestamp, s.pers_id_registerer, "
+ " s.samp_id_generated_from, s.samp_id_part_of, s.saty_id, s.inva_id "
+ " from samples s where s.expe_id=?{1}", fetchSize = FETCH_SIZE)
......@@ -152,7 +152,7 @@ public interface ISampleListingQuery extends TransactionQuery, IPropertyListingQ
/**
* Returns the samples for the given <var>sampleContainerId</var>.
*/
@Select(sql = "select s.id, s.perm_id, s.code, s.expe_id, s.grou_id, "
@Select(sql = "select s.id, s.perm_id, s.code, s.expe_id, s.grou_id, s.dbin_id, "
+ " s.registration_timestamp, s.pers_id_registerer, "
+ " s.samp_id_generated_from, s.samp_id_part_of, s.saty_id, s.inva_id "
+ " from samples s where s.samp_id_part_of=?{1}", fetchSize = FETCH_SIZE)
......@@ -165,7 +165,7 @@ public interface ISampleListingQuery extends TransactionQuery, IPropertyListingQ
/**
* Returns the shared samples for the given <var>dbInstanceId</var>.
*/
@Select(sql = "select s.id, s.perm_id, s.code, s.expe_id, "
@Select(sql = "select s.id, s.perm_id, s.code, s.expe_id, s.dbin_id, "
+ " s.registration_timestamp, s.pers_id_registerer, "
+ " s.samp_id_generated_from, s.samp_id_part_of, s.saty_id, s.inva_id "
+ " from samples s join sample_types st on s.saty_id=st.id "
......@@ -175,7 +175,7 @@ public interface ISampleListingQuery extends TransactionQuery, IPropertyListingQ
/**
* Returns the shared samples for the given <var>dbInstanceId</var> and <var>sampleTypeId</var>.
*/
@Select(sql = "select s.id, s.perm_id, s.code, s.expe_id, "
@Select(sql = "select s.id, s.perm_id, s.code, s.expe_id, s.dbin_id, "
+ " s.registration_timestamp, s.pers_id_registerer, "
+ " s.samp_id_generated_from, s.samp_id_part_of, s.saty_id, s.inva_id "
+ " from samples s where s.dbin_id=?{1} and s.saty_id=?{2} order by s.code", fetchSize = FETCH_SIZE)
......@@ -222,7 +222,7 @@ public interface ISampleListingQuery extends TransactionQuery, IPropertyListingQ
/**
* Returns the samples for the given <var>sampleIds</var>.
*/
@Select(sql = "select s.id, s.perm_id, s.code, s.expe_id, s.grou_id, "
@Select(sql = "select s.id, s.perm_id, s.code, s.expe_id, s.grou_id, s.dbin_id, "
+ " s.registration_timestamp, s.pers_id_registerer, "
+ " s.samp_id_generated_from, s.samp_id_part_of, s.saty_id, s.inva_id "
+ " from samples s where s.id = any(?{1})", parameterBindings =
......
......@@ -408,16 +408,19 @@ final class SampleListingWorker
final boolean primarySample = (sampleListOrNull != null);
for (SampleRecord row : sampleIteratorOrNull)
{
final Sample sample = createSample(row, baseIndexURLOrNull, primarySample);
sampleMap.put(sample.getId(), sample);
if (sampleListOrNull != null)
final Sample sampleOrNull = tryCreateSample(row, baseIndexURLOrNull, primarySample);
if (sampleOrNull != null) // null == different db instance
{
sampleListOrNull.add(sample);
sampleMap.put(sampleOrNull.getId(), sampleOrNull);
if (sampleListOrNull != null)
{
sampleListOrNull.add(sampleOrNull);
}
}
}
}
private Sample createSample(SampleRecord row, final String baseIndexURLOrNull,
private Sample tryCreateSample(SampleRecord row, final String baseIndexURLOrNull,
final boolean primarySample)
{
final Sample sample = new Sample();
......@@ -428,10 +431,25 @@ final class SampleListingWorker
// set group or instance
if (row.grou_id == null)
{
setDatabaseInstance(sample);
if (row.dbin_id.equals(databaseInstanceId))
{
setDatabaseInstance(sample);
} else
// different db instance
{
return null;
}
} else
{
setGroup(sample, groupMap.get(row.grou_id));
final Group groupOrNull = groupMap.get(row.grou_id);
if (groupOrNull != null)
{
setGroup(sample, groupMap.get(row.grou_id));
} else
// different db instance
{
return null;
}
}
// set properties needed for primary samples
if (primarySample)
......
......@@ -30,9 +30,11 @@ public class SampleRecord extends CodeRecord
public String perm_id;
public Long expe_id;
public Long grou_id;
public Long dbin_id;
public Long samp_id_generated_from;
public Long samp_id_part_of;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment