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
55498871
Commit
55498871
authored
10 years ago
by
juanf
Browse files
Options
Downloads
Patches
Plain Diff
SSDM-1211 : V3 API - JS facade (Ultimate JS Generator Ongoing work)
SVN: 32927
parent
b91fb899
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_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/generators/UltimateJSEntityGenerator.java
+26
-2
26 additions, 2 deletions
...ared/api/v3/dto/generators/UltimateJSEntityGenerator.java
with
26 additions
and
2 deletions
openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/generators/UltimateJSEntityGenerator.java
+
26
−
2
View file @
55498871
package
ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators
;
import
java.io.BufferedReader
;
import
java.io.BufferedWriter
;
import
java.io.FileNotFoundException
;
import
java.io.FileOutputStream
;
import
java.io.FileReader
;
import
java.io.IOException
;
import
java.io.OutputStreamWriter
;
import
java.io.UnsupportedEncodingException
;
import
java.io.Writer
;
public
class
UltimateJSEntityGenerator
{
...
...
@@ -35,11 +41,17 @@ public class UltimateJSEntityGenerator
public
static
void
main
(
String
[]
args
)
throws
IOException
{
for
(
String
classToConvert:
CLASSES_TO_CONVERT
)
{
String
jsClass
=
translateFromJavaToJS
(
readFileAsString
(
API_PROJECT_SOURCE_FOLDER
+
classToConvert
.
replace
(
'.'
,
'/'
)
+
".java"
));
System
.
out
.
println
(
jsClass
);
String
javaClass
=
readFileAsString
(
API_PROJECT_SOURCE_FOLDER
+
classToConvert
.
replace
(
'.'
,
'/'
)
+
".java"
);
String
jsClass
=
translateFromJavaToJS
(
javaClass
);
whriteStringAsFile
(
JSTEST_PROJECT_SOURCE_FOLDER
+
getSimpleName
(
classToConvert
)
+
".js"
,
jsClass
);
// System.out.println(jsClass);
}
}
private
static
String
getSimpleName
(
String
fullClassName
)
{
int
lastIndexOfDot
=
fullClassName
.
lastIndexOf
(
'.'
);
return
fullClassName
.
substring
(
lastIndexOfDot
+
1
);
}
private
static
final
String
translateFromJavaToJS
(
String
toTranslate
)
{
return
toTranslate
//Remove Java specific features
...
...
@@ -65,6 +77,18 @@ public class UltimateJSEntityGenerator
.
replaceAll
(
"(?:/\\*(?:[^*]|(?:\\*+[^*/]))*\\*+/)|(?://.*)"
,
""
);
}
private
static
final
void
whriteStringAsFile
(
String
filePath
,
String
string
)
throws
IOException
{
Writer
out
=
null
;
try
{
out
=
new
BufferedWriter
(
new
OutputStreamWriter
(
new
FileOutputStream
(
filePath
),
"UTF-8"
));
out
.
write
(
string
);
}
finally
{
out
.
close
();
}
}
private
static
final
String
readFileAsString
(
String
filePath
)
throws
IOException
{
StringBuffer
fileData
=
new
StringBuffer
();
BufferedReader
reader
=
new
BufferedReader
(
new
FileReader
(
filePath
));
...
...
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