diff --git a/plasmid/.classpath b/plasmid/.classpath index c47ea7faecb29fac8d855243195e552942a0b091..89bf23efa0e6878542e27f8051355654f0602b1e 100644 --- a/plasmid/.classpath +++ b/plasmid/.classpath @@ -17,5 +17,6 @@ <classpathentry kind="lib" path="/libraries/commons-lang/commons-lang.jar" sourcepath="/libraries/commons-lang/src.zip"/> <classpathentry kind="lib" path="/libraries/commons-io/commons-io.jar" sourcepath="/libraries/commons-io/src.zip"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry combineaccessrules="false" kind="src" path="/openbis-ipad"/> <classpathentry kind="output" path="targets/classes"/> </classpath> diff --git a/plasmid/.project b/plasmid/.project index 9545da1ac03f004beeda24cd6995cf51b2bf2944..93d890b5827a38df5ca139076cc2d33d73e4bc97 100644 --- a/plasmid/.project +++ b/plasmid/.project @@ -14,15 +14,15 @@ <natures> <nature>org.eclipse.jdt.core.javanature</nature> </natures> - <filteredResources> - <filter> - <id>1332321366607</id> - <name></name> - <type>26</type> - <matcher> - <id>org.eclipse.ui.ide.multiFilter</id> - <arguments>1.0-name-matches-true-false-.git</arguments> - </matcher> - </filter> - </filteredResources> + <filteredResources> + <filter> + <id>1332321366607</id> + <name></name> + <type>26</type> + <matcher> + <id>org.eclipse.ui.ide.multiFilter</id> + <arguments>1.0-name-matches-true-false-.git</arguments> + </matcher> + </filter> + </filteredResources> </projectDescription> diff --git a/plasmid/source/java/ch/ethz/bsse/cisd/yeastlab/ipad/v2/server/IpadYeastlabUtilities.java b/plasmid/source/java/ch/ethz/bsse/cisd/yeastlab/ipad/v2/server/IpadYeastlabUtilities.java new file mode 100644 index 0000000000000000000000000000000000000000..af13e83aea2792adb188877840fcac6093b89643 --- /dev/null +++ b/plasmid/source/java/ch/ethz/bsse/cisd/yeastlab/ipad/v2/server/IpadYeastlabUtilities.java @@ -0,0 +1,80 @@ +/* + * Copyright 2013 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.bsse.cisd.yeastlab.ipad.v2.server; + +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import ch.systemsx.cisd.etlserver.registrator.api.v1.ISample; +import ch.systemsx.cisd.openbis.ipad.v2.server.IpadServiceUtilities; + +/** + * @author cramakri + */ +public class IpadYeastlabUtilities +{ + + /** + * Return a collection of properties, ordered by display ordering, skipping propsToIgnore. + */ + public static List<String> orderedPropertiesForSampleIgnoring(ISample sample, + List<String> propsToIgnore) + { + return null; + } + + /** + * Convert a sample to a dictionary, ignoring the specified properties. + * <p> + * <ul> + * <li>Uses the NAME property to construct the summary.</li> + * <li>Returns empty children.</li> + * <li>Callers may need to modify the summary and children as well</li> + * </ul> + */ + public static Map<String, Object> samplToDictWithPropsIgnoring(ISample sample, + boolean wantProps, List<String> propsToIgnore) + { + HashMap<String, Object> sampleDict = new HashMap<String, Object>(); + sampleDict.put("SUMMARY_HEADER", sample.getCode()); + String name = sample.getPropertyValue("NAME"); + String summary = (null != name) ? "Name: " + name : "??"; + sampleDict.put("SUMMARY", summary); + sampleDict.put("IDENTIFIER", sample.getSampleIdentifier()); + sampleDict.put("PERM_ID", sample.getPermId()); + + HashMap<String, String> refconSample = new HashMap<String, String>(); + refconSample.put("code", sample.getCode()); + refconSample.put("entityKind", "SAMPLE"); + refconSample.put("entityType", sample.getSampleType()); + sampleDict.put("REFCON", IpadServiceUtilities.jsonEncodedValue(refconSample)); + sampleDict.put("CATEGORY", sample.getSampleType()); + sampleDict.put("CHILDREN", IpadServiceUtilities.jsonEncodedValue(Collections.emptyList())); + + if (wantProps) + { + List<String> sampleProperties = + orderedPropertiesForSampleIgnoring(sample, propsToIgnore); + sampleDict.put("PROPERTIES", IpadServiceUtilities.jsonEncodedValue(sampleProperties)); + } + + sampleDict.put("ROOT_LEVEL", false); + return sampleDict; + } +}