diff --git a/README.md b/README.md index 552d98aae3a500aa584f179aab074a6d26165052..84902e209f934bedbade23be7f39cb387eb17b2b 100644 --- a/README.md +++ b/README.md @@ -62,9 +62,10 @@ openbis.bundle.min.js ## Requirements +- Software Requirements - IntelliJ IDEA CE -## Step By Step: +## Step By Step ``` File -> New -> Project From Existing Sources @@ -76,6 +77,50 @@ openBISDevelopementEnvironmentASStart openBISDevelopementEnvironmentDSSStart ``` +## Source Code Auto Formatting + +OpenBIS source code uses a particular style preset that guarantees all code is formatted uniformly. + +To make use of the preset go to File/Settings or IntelliJIDEA/Preferences depending on your OS. + +Then import the XML file under 'docs/codestyle/SIS_Conventions_IntelliJ_V3.xml'. See images below: + + + + + + +## Commit Messages Formatting + +OpenBIS source code commit messages use a particular formatting. + +This formatting guarantees that there is a User Story behind it. + +To ensure commits follow the formatting 'Git Hooks' are provided. + +Just copy them from the root folder of this repo run the next command: +```` +%/> cp ./docs/hooks/* ./.git/hooks/ +%/> git add README.md +%/> git commit -m "Test incorrectly formatted message" +Aborting commit. Your commit message is missing an issue number ('SSDM-XXXXX:') +```` + +## Source Code Copyright Header + +OpenBIS source code is licensed under SIS copyright and licensed under 'Apache 2 License': +```` +http://www.apache.org/licenses/LICENSE-2.0 +```` +To guarantee all new source files contain the appropriate license a preset is provided. + +To make use of the preset go to File/Settings or IntelliJIDEA/Preferences depending on your OS. + +Then import the XML file under 'docs/copyright/Copyright_IntelliJ.xml' under the copyright section as the image below indicate. + +Last, set the Copyright Profile under the Copyright section as the image below indicate: + + ## Typical Errors # IntelliJ can't find package com.sun.*, but I can compile the project using the command line! @@ -83,22 +128,19 @@ openBISDevelopementEnvironmentDSSStart Turn off "File | Settings | Build, Execution, Deployment | Compiler | Java Compiler | Use --release option for cross-compilation". -# IntelliJ can't find a particular method: +# IntelliJ can't find a particular method Code compatiblity 1.8 is set by default to work well with our javadoc tools but it can be set to 17 on IntelliJ. See image below. -  -# Test seem to run through Gradle and fail: +# Test seem to run through Gradle and fail They need to be set to run using IntelliJ. -  -# Test seem to run through intelliJ but throw a package not open error: +# Test seem to run through intelliJ but throw a package not open error The project does not uses modules yet. Add '--add-opens' statements manually when launching the tests as shown below. -  ## Development of NG UI @@ -119,33 +161,4 @@ The project does not uses modules yet. Add '--add-opens' statements manually whe ## Setting up IntelliJ Idea 1. Under "IntelliJ IDEA" -> "Preferences" -> "Languages and Frameworks" -> Javascript, set the - language version to ECMAScript 6. - -## Coding Style - -openBIS source code uses a particular style preset that guarantees all code is formatted uniformly. - -To make use of the preset go to File/Settings or IntelliJIDEA/Preferences depending on your OS. - -Then import the XML file under 'docs/CISD_Conventions_IntelliJ_V2.xml'. See images below. - - - - - - -## Git Hooks - -openBIS source code commit messages use a particular formatting. - -This formatting guarantees that there is a User Story behind it. - -To ensure commits follow the formatting 'Git Hooks' are provided. - -Just copy them from the root folder of this repo run the next command: -```` -%/> cp ./docs/hooks/* ./.git/hooks/ -%/> git add README.md -%/> git commit -m "Test incorrectly formatted message" -Aborting commit. Your commit message is missing an issue number ('SSDM-XXXXX:') -```` \ No newline at end of file + language version to ECMAScript 6. \ No newline at end of file diff --git a/docs/copyright/Copyright_IntelliJ.xml b/docs/copyright/Copyright_IntelliJ.xml index e80bdd78ea80669ad17dd6a1e94d2be58780cc8f..aa5e8abb70629edd57234526ca4fdac4317fe022 100644 --- a/docs/copyright/Copyright_IntelliJ.xml +++ b/docs/copyright/Copyright_IntelliJ.xml @@ -1,6 +1,6 @@ <component name="CopyrightManager"> <copyright> <option name="notice" value=" Copyright ETH &#36;originalComment.match("Copyright ETH (\d+)", 1, " - ", "&#36;today.year")&#36;today.year Zürich, 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. " /> - <option name="myName" value="Copyright" /> + <option name="myName" value="Copyright SIS - License Apache 2" /> </copyright> </component> \ No newline at end of file diff --git a/docs/readme/intellij-copyright-config-1.png b/docs/readme/intellij-copyright-config-1.png new file mode 100644 index 0000000000000000000000000000000000000000..62a2f2a2b1bf4684c87920922cd0233c419dd09b Binary files /dev/null and b/docs/readme/intellij-copyright-config-1.png differ diff --git a/docs/readme/intellij-copyright-config-2.png b/docs/readme/intellij-copyright-config-2.png new file mode 100644 index 0000000000000000000000000000000000000000..80a0b96756283fedb118a38ee0b46d460202e916 Binary files /dev/null and b/docs/readme/intellij-copyright-config-2.png differ diff --git a/ui-eln-lims/src/core-plugins/eln-lims/1/dss/file-system-plugins/eln-tree/resolver-plugins/microscopy.py b/ui-eln-lims/src/core-plugins/eln-lims/1/dss/file-system-plugins/eln-tree/resolver-plugins/microscopy.py index 36571d8a4e6226bd8ad41c7ce05954c2a52637a7..e2d4f56fde2a475d36106902372b3b5e852f59ab 100644 --- a/ui-eln-lims/src/core-plugins/eln-lims/1/dss/file-system-plugins/eln-tree/resolver-plugins/microscopy.py +++ b/ui-eln-lims/src/core-plugins/eln-lims/1/dss/file-system-plugins/eln-tree/resolver-plugins/microscopy.py @@ -1,3 +1,27 @@ +from ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.search import DataSetSearchCriteria +from ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.fetchoptions import DataSetFetchOptions + +import script + acceptor.hideDataSetType("MICROSCOPY_IMG_CONTAINER") acceptor.hideDataSetType("MICROSCOPY_IMG_OVERVIEW") acceptor.hideDataSetType("MICROSCOPY_IMG_THUMBNAIL") +#acceptor.hideSampleType("MICROSCOPY_SAMPLE_TYPE") + +def addSampleChildNodes(path, samplePermId, sampleType, response, acceptor, context): + dataSetSearchCriteria = DataSetSearchCriteria() + parentsSearchCriteria = dataSetSearchCriteria.withSample().withParents() + parentsSearchCriteria.withPermId().thatEquals(samplePermId) + fetchOptions = DataSetFetchOptions() + fetchOptions.withType() + fetchOptions.withProperties() + fetchOptions.withSample() + dataSets = context.getApi().searchDataSets(context.getSessionToken(), dataSetSearchCriteria, fetchOptions).getObjects() + for dataSet in dataSets: + if acceptor.acceptDataSet(dataSet): + dataSetCode = dataSet.getCode() + content = context.getContentProvider().asContent(dataSetCode) + contentNode = content.getRootNode() + script.addDataSetFileNodes(path, dataSetCode, contentNode, response, acceptor, context) + +acceptor.sampleChildrenHandlers["MICROSCOPY_EXPERIMENT"] = addSampleChildNodes diff --git a/ui-eln-lims/src/core-plugins/eln-lims/1/dss/file-system-plugins/eln-tree/script.py b/ui-eln-lims/src/core-plugins/eln-lims/1/dss/file-system-plugins/eln-tree/script.py index c4d8881db8846d211e4057fd6239abf2dc98edde..1bfc219846fb319352ef61f54b1b4312ab0bf0af 100644 --- a/ui-eln-lims/src/core-plugins/eln-lims/1/dss/file-system-plugins/eln-tree/script.py +++ b/ui-eln-lims/src/core-plugins/eln-lims/1/dss/file-system-plugins/eln-tree/script.py @@ -21,10 +21,15 @@ class NodeWithEntityType(Node): def __init__(self, type, permId, entityType): super(NodeWithEntityType, self).__init__(type, permId) self.entityType = entityType + self.permIds = set() + self.addPermId(permId) def getEntityType(self): return self.entityType + def addPermId(self, permId): + self.permIds.add(permId) + class Acceptor(object): def __init__(self, settings): self.sections = ["Lab Notebook", "Inventory", "Stock"] @@ -38,6 +43,7 @@ class Acceptor(object): self.hiddenExperimentTypes = {} self.hiddenSampleTypes = {} self.hiddenDataSetTypes = {} + self.sampleChildrenHandlers = {} def assertValidSection(self, section): if section not in self.sections: @@ -93,15 +99,7 @@ class Acceptor(object): self.hiddenSampleTypes[typeCode] = True def acceptSample(self, sample): - group = self._getGroupPrefix(sample.getSpace().getCode()) - attributes = self.sampleTypeViewAttributes[group] - sampleTypeCode = sample.getType().getCode() - if sampleTypeCode in self.hiddenSampleTypes: - return False - if sampleTypeCode in attributes: - attr = attributes[sampleTypeCode] - return "SHOW_ON_NAV" in attr and attr["SHOW_ON_NAV"] - return False + return sample.getType().getCode() not in self.hiddenSampleTypes def hideDataSetType(self, typeCode): self.hiddenDataSetTypes[typeCode] = True @@ -234,13 +232,16 @@ def listChildren(subPath, acceptor, context): nodeType = node.getType() permId = node.getPermId() if nodeType == "DATASET": - dataSetCode, contentNode, content = getContentNode(permId, context) - if contentNode.isDirectory(): - response = context.createDirectoryResponse() - addDataSetFileNodes(path, dataSetCode, contentNode, response, acceptor, context) - return response - else: - return context.createFileResponse(contentNode, content) + response = None + for permId in node.permIds: + dataSetCode, contentNode, content = getContentNode(permId, context) + if contentNode.isDirectory(): + if response is None: + response = context.createDirectoryResponse() + addDataSetFileNodes(path, dataSetCode, contentNode, response, acceptor, context) + else: + response = context.createFileResponse(contentNode, content) + return response elif nodeType == "SAMPLE": response = context.createDirectoryResponse() addSampleChildNodes(path, permId, node.getEntityType(), response, acceptor, context) @@ -259,11 +260,13 @@ def getNode(subPath, acceptor, context): nodeType = parentNode.getType() entityType = parentNode.getEntityType() permId = parentNode.getPermId() + print(">>>>>>>>>> GET NODE: %s, %s, %s" % (path, nodeType, parentNode.permIds)) if nodeType == "EXPERIMENT": addExperimentChildNodes(parentPathString, permId, entityType, None, acceptor, context) elif nodeType == "SAMPLE": addSampleChildNodes(parentPathString, permId, entityType, None, acceptor, context) elif nodeType == "DATASET": + print("====== GET DATASET NODE: %s, %s" % (path, parentNode.permIds)) dataSetCode, contentNode, _ = getContentNode(parentNode.getPermId(), context) addDataSetFileNodes(parentPathString, dataSetCode, contentNode, None, acceptor, context) else: @@ -307,6 +310,9 @@ def addExperimentChildNodes(path, experimentPermId, experimentType, response, ac addNodes("SAMPLE", entitiesByName, path, response, context) def addSampleChildNodes(path, samplePermId, sampleType, response, acceptor, context): + if sampleType in acceptor.sampleChildrenHandlers: + acceptor.sampleChildrenHandlers[sampleType](path, samplePermId, sampleType, response, acceptor, context) + return dataSetSearchCriteria = DataSetSearchCriteria() dataSetSearchCriteria.withSample().withPermId().thatEquals(samplePermId) @@ -335,12 +341,16 @@ def addDataSetFileNodes(path, dataSetCode, contentNode, response, acceptor, cont nodeName = childNode.getName() filePath = "%s/%s" % (path, nodeName) filePermId = "%s::%s" % (dataSetCode, childNode.getRelativePath()) - context.getCache().putNode(NodeWithEntityType("DATASET", filePermId, None), filePath) - if response is not None: - if childNode.isDirectory(): - response.addDirectory(nodeName, childNode.getLastModified()) - else: - response.addFile(nodeName, childNode) + cachedNode = context.getCache().getNode(filePath) + if cachedNode is not None: + cachedNode.addPermId(filePermId) + else: + context.getCache().putNode(NodeWithEntityType("DATASET", filePermId, None), filePath) + if response is not None: + if childNode.isDirectory(): + response.addDirectory(nodeName, childNode.getLastModified()) + else: + response.addFile(nodeName, childNode) def getContentNode(permId, context): splittedId = permId.split("::")