Skip to content
Snippets Groups Projects
Commit 35f6fdc8 authored by Adam Laskowski's avatar Adam Laskowski
Browse files

Merge remote-tracking branch 'origin/master'

parents 0e45ff28 646503ff
No related branches found
No related tags found
1 merge request!40SSDM-13578 : 2PT : Database and V3 Implementation - include the new AFS "free"...
......@@ -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:
!["IntelliJ Code Style Configuration 1"](./docs/readme/intellij-codestyle-config-1.png "IntelliJ Code Style Configuration 1")
!["IntelliJ Code Style Configuration 2"](./docs/readme/intellij-codestyle-config-2.png "IntelliJ Code Style Configuration 2")
!["IntelliJ Code Style Configuration 3"](./docs/readme/intellij-codestyle-config-3.png "IntelliJ Code Style Configuration 3")
!["IntelliJ Code Style Configuration 4"](./docs/readme/intellij-codestyle-config-4.png "IntelliJ Code Style Configuration 4")
## 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.
!["IntelliJ Copyright Configuration 1"](./docs/readme/intellij-copyright-config-1.png "IntelliJ Copyright Configuration 1")
Last, set the Copyright Profile under the Copyright section as the image below indicate:
!["IntelliJ Copyright Configuration 2"](./docs/readme/intellij-copyright-config-2.png "IntelliJ Copyright Configuration 2")
## 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.
!["IntelliJ Configuration 1"](./docs/readme/intellij-config-1.png "IntelliJ Configuration 1")
# 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.
!["IntelliJ Configuration 2"](./docs/readme/intellij-config-2.png "IntelliJ Configuration 2")
# 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.
!["IntelliJ Configuration 3"](./docs/readme/intellij-config-3.png "IntelliJ Configuration 3")
## 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.
!["IntelliJ Code Style Configuration 1"](./docs/readme/intellij-codestyle-config-1.png "IntelliJ Code Style Configuration 1")
!["IntelliJ Code Style Configuration 2"](./docs/readme/intellij-codestyle-config-2.png "IntelliJ Code Style Configuration 2")
!["IntelliJ Code Style Configuration 3"](./docs/readme/intellij-codestyle-config-3.png "IntelliJ Code Style Configuration 3")
!["IntelliJ Code Style Configuration 4"](./docs/readme/intellij-codestyle-config-4.png "IntelliJ Code Style Configuration 4")
## 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
<component name="CopyrightManager">
<copyright>
<option name="notice" value=" Copyright ETH &amp;#36;originalComment.match(&quot;Copyright ETH (\d+)&quot;, 1, &quot; - &quot;, &quot;&amp;#36;today.year&quot;)&amp;#36;today.year Zürich, Scientific IT Services&#10; &#10; Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);&#10; you may not use this file except in compliance with the License.&#10; You may obtain a copy of the License at&#10; &#10; http://www.apache.org/licenses/LICENSE-2.0&#10; &#10; Unless required by applicable law or agreed to in writing, software&#10; distributed under the License is distributed on an &quot;AS IS&quot; BASIS,&#10; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.&#10; See the License for the specific language governing permissions and&#10; limitations under the License.&#10;" />
<option name="myName" value="Copyright" />
<option name="myName" value="Copyright SIS - License Apache 2" />
</copyright>
</component>
\ No newline at end of file
docs/readme/intellij-copyright-config-1.png

756 KiB

docs/readme/intellij-copyright-config-2.png

627 KiB

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
......@@ -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("::")
......
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