From 388e7b91ace64f52934d0dde500332d301d7c8e2 Mon Sep 17 00:00:00 2001 From: cramakri <cramakri> Date: Tue, 21 May 2013 08:50:46 +0000 Subject: [PATCH] CCS-35 SP-627 : Make yeastlab ipad app use new java infrastructure SVN: 29173 --- plasmid/.classpath | 1 + plasmid/.project | 22 ++--- .../ipad/v2/server/IpadYeastlabUtilities.java | 80 +++++++++++++++++++ 3 files changed, 92 insertions(+), 11 deletions(-) create mode 100644 plasmid/source/java/ch/ethz/bsse/cisd/yeastlab/ipad/v2/server/IpadYeastlabUtilities.java diff --git a/plasmid/.classpath b/plasmid/.classpath index c47ea7faecb..89bf23efa0e 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 9545da1ac03..93d890b5827 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 00000000000..af13e83aea2 --- /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; + } +} -- GitLab