Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openbis
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sispub
openbis
Commits
191a4cb3
Commit
191a4cb3
authored
8 years ago
by
juanf
Browse files
Options
Downloads
Patches
Plain Diff
SSDM-3092 : Export functionality, ongoing work
SVN: 36599
parent
770c09bf
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
openbis_standard_technologies/dist/core-plugins/eln-lims/1/dss/reporting-plugins/exports-api/exports-api.py
+35
-9
35 additions, 9 deletions
...n-lims/1/dss/reporting-plugins/exports-api/exports-api.py
with
35 additions
and
9 deletions
openbis_standard_technologies/dist/core-plugins/eln-lims/1/dss/reporting-plugins/exports-api/exports-api.py
+
35
−
9
View file @
191a4cb3
...
@@ -19,16 +19,21 @@ import time
...
@@ -19,16 +19,21 @@ import time
#Java Core
#Java Core
from
java.io
import
ByteArrayInputStream
from
java.io
import
ByteArrayInputStream
from
org.apache.commons.io
import
IOUtils
from
java.lang
import
String
from
java.lang
import
String
#Zip Format
from
java.io
import
File
;
from
java.io
import
FileInputStream
;
from
java.io
import
FileNotFoundException
;
from
java.io
import
FileOutputStream
;
from
java.util.zip
import
ZipEntry
;
from
java.util.zip
import
ZipOutputStream
;
#To obtain the openBIS URL
#To obtain the openBIS URL
from
ch.systemsx.cisd.openbis.dss.generic.server
import
DataStoreServer
from
ch.systemsx.cisd.openbis.dss.generic.server
import
DataStoreServer
from
__builtin__
import
None
OPENBISURL
=
DataStoreServer
.
getConfigParameters
().
getServerURL
()
+
"
/openbis/openbis
"
OPENBISURL
=
DataStoreServer
.
getConfigParameters
().
getServerURL
()
+
"
/openbis/openbis
"
#V1 API - To manage session workspace
from
ch.systemsx.cisd.openbis.dss.client.api.v1
import
DssComponentFactory
#V3 API
#V3 API
from
ch.systemsx.cisd.common.spring
import
HttpInvokerUtils
;
from
ch.systemsx.cisd.common.spring
import
HttpInvokerUtils
;
from
ch.ethz.sis.openbis.generic.asapi.v3
import
IApplicationServerApi
from
ch.ethz.sis.openbis.generic.asapi.v3
import
IApplicationServerApi
...
@@ -139,13 +144,32 @@ def getFileName(rootDir, spaceCode, projCode, expCode, sampCode, dataCode, ext):
...
@@ -139,13 +144,32 @@ def getFileName(rootDir, spaceCode, projCode, expCode, sampCode, dataCode, ext):
fileName
+=
"
.
"
+
ext
;
fileName
+=
"
.
"
+
ext
;
return
fileName
;
return
fileName
;
def
addToZipFile
(
fileName
,
zos
):
file
=
File
(
fileName
);
fis
=
FileInputStream
(
file
);
zipEntry
=
ZipEntry
(
fileName
);
zos
.
putNextEntry
(
zipEntry
);
bytes
=
byte
[
1024
];
length
=
fis
.
read
(
bytes
);
while
length
>=
0
:
zos
.
write
(
bytes
,
0
,
length
);
length
=
fis
.
read
(
bytes
);
zos
.
closeEntry
();
fis
.
close
();
def
export
(
tr
,
params
):
def
export
(
tr
,
params
):
sessionToken
=
params
.
get
(
"
sessionToken
"
);
sessionToken
=
params
.
get
(
"
sessionToken
"
);
v3
=
HttpInvokerUtils
.
createServiceStub
(
IApplicationServerApi
,
OPENBISURL
+
IApplicationServerApi
.
SERVICE_URL
,
30
*
1000
);
v3
=
HttpInvokerUtils
.
createServiceStub
(
IApplicationServerApi
,
OPENBISURL
+
IApplicationServerApi
.
SERVICE_URL
,
30
*
1000
);
objectMapper
=
GenericObjectMapper
();
objectMapper
=
GenericObjectMapper
();
objectMapper
.
enable
(
SerializationFeature
.
INDENT_OUTPUT
);
objectMapper
.
enable
(
SerializationFeature
.
INDENT_OUTPUT
);
dss_component
=
DssComponentFactory
.
tryCreate
(
params
.
get
(
"
sessionToken
"
),
OPENBISURL
);
rootDir
=
str
(
time
.
time
());
#Create temporal folder
rootDirFile
=
File
.
createTempFile
(
str
(
time
.
time
()),
None
);
rootDirFile
.
delete
();
rootDirFile
.
mkdir
();
rootDir
=
rootDirFile
.
getCanonicalPath
();
for
entity
in
params
.
get
(
"
entities
"
):
for
entity
in
params
.
get
(
"
entities
"
):
type
=
entity
[
"
type
"
];
type
=
entity
[
"
type
"
];
...
@@ -208,7 +232,9 @@ def export(tr, params):
...
@@ -208,7 +232,9 @@ def export(tr, params):
if
entityObj
is
not
None
and
entityFilePath
is
not
None
:
if
entityObj
is
not
None
and
entityFilePath
is
not
None
:
entityJson
=
String
(
objectMapper
.
writeValueAsString
(
entityObj
));
entityJson
=
String
(
objectMapper
.
writeValueAsString
(
entityObj
));
dss_component
.
putFileToSessionWorkspace
(
entityFilePath
,
ByteArrayInputStream
(
entityJson
.
getBytes
()));
entityFile
=
File
(
entityFilePath
);
print
entityJson
;
entityFile
.
getParentFile
().
mkdirs
();
IOUtils
.
write
(
entityJson
.
getBytes
(),
FileOutputStream
(
entityFile
));
print
"
Folder found at:
"
+
rootDir
return
True
return
True
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment