Skip to content
GitLab
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
TDL Open Source
TOP IDE
Compare revisions
30ecb3b30a4ccf4b6365211344e1b5c9850c9f93...c345caf414cd85fa0d024cea76695ff00386d5f3
Hide whitespace changes
Inline
Side-by-side
plugins/org.etsi.mts.tdl.execution.java.runtime/src/org/etsi/mts/tdl/execution/java/tri/Verdict.java
View file @
c345caf4
...
...
@@ -3,14 +3,5 @@ package org.etsi.mts.tdl.execution.java.tri;
/**
* Either predefined or custom verdict.
*/
public
class
Verdict
extends
NamedElement
{
/**
* Verdict instance predefined in TDL.
*/
public
static
Verdict
pass
=
new
Verdict
(
"pass"
),
fail
=
new
Verdict
(
"fail"
),
inconclusive
=
new
Verdict
(
"inconclusive"
);
public
Verdict
(
String
name
)
{
super
(
name
,
null
);
}
public
interface
Verdict
extends
NamedElement
{
}
plugins/org.etsi.mts.tdl.execution.java/src/org/etsi/mts/tdl/execution/java/codegen/JUnitTestGenerator.java
View file @
c345caf4
...
...
@@ -248,7 +248,8 @@ public class JUnitTestGenerator extends Renderer {
}
private
Annotation
getAnnotation
(
Element
e
,
String
keyName
)
{
Optional
<
Annotation
>
op
=
e
.
getAnnotation
().
stream
().
filter
(
a
->
a
.
getKey
().
getName
().
equals
(
keyName
)).
findAny
();
Optional
<
Annotation
>
op
=
e
.
getAnnotation
().
stream
().
filter
(
a
->
a
.
getKey
().
getName
().
equals
(
keyName
))
.
findAny
();
if
(
op
.
isPresent
())
return
op
.
get
();
return
null
;
...
...
@@ -499,7 +500,7 @@ public class JUnitTestGenerator extends Renderer {
connectionNames
.
add
(
connectionName
);
List
<
GateReference
>
endpoints
=
conn
.
getEndPoint
();
append
(
"Connection "
+
connectionName
+
" = new Connection"
);
append
(
"Connection "
+
connectionName
+
" = new Connection
Impl
"
);
callOpen
();
line
(
"\""
+
conn
.
getName
()
+
"\", "
);
writeGateReference
(
endpoints
.
get
(
0
));
...
...
@@ -523,11 +524,13 @@ public class JUnitTestGenerator extends Renderer {
}
private
void
writeGateReference
(
GateReference
e
)
{
append
(
"new GateReference("
);
append
(
"new GateReference
Impl
("
);
writeElement
(
e
.
getGate
());
append
(
", "
);
writeElement
(
e
.
getGate
().
getType
());
append
(
", "
);
append
(
"GateTypeKind."
+
e
.
getGate
().
getType
().
getKind
());
append
(
", "
);
writeElement
(
e
.
getComponent
());
append
(
", "
);
writeElement
(
e
.
getComponent
().
getType
());
...
...
@@ -611,7 +614,7 @@ public class JUnitTestGenerator extends Renderer {
declareType
(
iType
,
declaredTypes
);
}
//TODO add mapping name to mapping
//
TODO add mapping name to mapping
DataElementMapping
mapping
=
getMapping
(
t
);
if
(
mapping
==
null
)
mapping
=
getMapping
(
t
,
settings
.
useMapping
);
...
...
@@ -645,11 +648,11 @@ public class JUnitTestGenerator extends Renderer {
private
void
writeMapping
(
DataElementMapping
mapping
,
String
mappingVarName
,
boolean
inline
)
{
Annotation
nameAnnotation
=
getAnnotation
(
mapping
.
getDataResourceMapping
(),
MAPPING_KEY
);
String
name
=
nameAnnotation
!=
null
?
nameAnnotation
.
getValue
()
:
null
;
String
name
=
nameAnnotation
!=
null
?
nameAnnotation
.
getValue
()
:
null
;
if
(!
inline
)
append
(
CORE_PACKAGE
+
".MappingImpl "
+
mappingVarName
+
" = "
);
append
(
"new "
+
CORE_PACKAGE
+
".MappingImpl("
);
append
(
"\""
+
name
+
"\", "
);
// XXX
...
...
@@ -693,7 +696,10 @@ public class JUnitTestGenerator extends Renderer {
}
private
void
writeElement
(
Element
e
)
{
append
(
"new Element(\""
+
e
.
getName
()
+
"\")"
);
if
(
e
instanceof
NamedElement
)
append
(
"new NamedElementImpl(\""
+
e
.
getName
()
+
"\", \""
+
((
NamedElement
)
e
).
getQualifiedName
()
+
"\")"
);
else
append
(
"new ElementImpl(\""
+
e
.
getName
()
+
"\")"
);
}
private
void
writeTestDescription
(
TestDescription
tc
)
{
...
...
plugins/org.etsi.mts.tdl.helper/src/org/etsi/mts/tdl/helper/TDLHelper.java
View file @
c345caf4
...
...
@@ -2,8 +2,8 @@ package org.etsi.mts.tdl.helper;
import
java.io.ByteArrayInputStream
;
import
java.io.IOException
;
import
java.net.URISyntaxException
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.HashSet
;
...
...
@@ -16,7 +16,9 @@ import org.eclipse.core.resources.IProject;
import
org.eclipse.core.resources.IResource
;
import
org.eclipse.core.resources.IResourceVisitor
;
import
org.eclipse.core.resources.IWorkspaceRoot
;
import
org.eclipse.core.resources.ResourcesPlugin
;
import
org.eclipse.core.runtime.CoreException
;
import
org.eclipse.core.runtime.NullProgressMonitor
;
import
org.eclipse.core.runtime.Path
;
import
org.eclipse.core.runtime.Platform
;
import
org.eclipse.emf.common.util.URI
;
...
...
@@ -43,7 +45,6 @@ import org.etsi.mts.tdl.TDLtxStandaloneSetup;
import
org.etsi.mts.tdl.TDLtxiStandaloneSetup
;
import
org.etsi.mts.tdl.TPLan2StandaloneSetup
;
import
org.etsi.mts.tdl.impl.tdlPackageImpl
;
import
org.etsi.mts.tdl.resources.ResourceHandler
;
import
org.etsi.mts.tdl.structuredobjectives.impl.StructuredObjectivesPackageImpl
;
import
org.osgi.framework.Bundle
;
...
...
@@ -141,9 +142,22 @@ public class TDLHelper {
* @param resource A resource to be saved.
* @throws Exception
*/
public
static
void
store
(
Resource
resource
)
throws
Exception
{
public
static
void
store
(
Resource
resource
,
boolean
derived
)
throws
Exception
{
if
(
derived
)
{
IFile
file
=
resourceToFile
(
resource
);
if
(
file
!=
null
)
{
if
(!
file
.
exists
())
file
.
create
(
new
ByteArrayInputStream
(
new
byte
[
0
]),
false
,
null
);
file
.
setDerived
(
derived
,
new
NullProgressMonitor
());
}
}
resource
.
save
(
Collections
.
emptyMap
());
}
public
static
IFile
resourceToFile
(
Resource
resource
)
{
URI
uri
=
resource
.
getURI
();
return
ResourcesPlugin
.
getWorkspace
().
getRoot
().
getFile
(
new
Path
(
uri
.
toPlatformString
(
true
)));
}
/**
...
...
plugins/org.etsi.mts.tdl.importers.ui/META-INF/MANIFEST.MF
View file @
c345caf4
...
...
@@ -20,7 +20,8 @@ Require-Bundle: org.eclipse.ui,
org.etsi.mts.tdl.openapi2tdl.next,
org.etsi.mts.tdl.to2tdl,
org.etsi.mts.tdl.json2tdl,
org.etsi.mts.tdl.yang2tdl
org.etsi.mts.tdl.yang2tdl,
org.etsi.mts.tdl.helper
Bundle-ActivationPolicy: lazy
Import-Package: org.eclipse.emf.common.util
Bundle-RequiredExecutionEnvironment: JavaSE-11
plugins/org.etsi.mts.tdl.importers.ui/src/org/etsi/mts/tdl/importers/ui/handlers/TranslationHandler.java
View file @
c345caf4
...
...
@@ -29,6 +29,7 @@ import org.eclipse.xtext.resource.XtextResourceSet;
import
org.eclipse.xtext.ui.resource.IResourceSetProvider
;
import
org.etsi.mts.tdl.Package
;
import
org.etsi.mts.tdl.asn2tdl.ASN2TDLTranslator
;
import
org.etsi.mts.tdl.helper.TDLHelper
;
import
org.etsi.mts.tdl.json2tdl.JSON2TDLTranslator
;
import
org.etsi.mts.tdl.openapi2tdl.next.OpenAPI2TDLTranslatorNext
;
import
org.etsi.mts.tdl.to2tdl.TO2TDLTranslator
;
...
...
@@ -163,7 +164,7 @@ public class TranslationHandler extends AbstractHandler {
}
if
(
translator
!=
null
)
{
translator
.
setTargetResource
(
tr
);
translator
.
initTargetResource
(
translator
.
c
leanName
(
file
.
getName
()));
translator
.
initTargetResource
(
translator
.
getC
leanName
(
file
.
getName
()));
try
{
translator
.
translate
(
filepath
);
}
catch
(
Exception
e
)
{
...
...
@@ -189,7 +190,7 @@ public class TranslationHandler extends AbstractHandler {
//tr.getContents().addAll(EcoreUtil.copyAll(r.getContents()));
try
{
tr
.
save
(
null
);
TDLHelper
.
store
(
tr
,
true
);
}
catch
(
Exception
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
...
...
plugins/org.etsi.mts.tdl.openapi2tdl.next/src/org/etsi/mts/tdl/openapi2tdl/next/ConverterNext.java
View file @
c345caf4
...
...
@@ -60,7 +60,7 @@ public class ConverterNext {
translator
.
initTargetResource
(
translator
.
cleanName
(
new
File
(
inputPath
).
getName
()));
translator
.
translate
(
inputPath
);
name
=
((
Package
)
tr
.
getContents
().
get
(
0
)).
getName
();
TDLHelper
.
store
(
tr
);
TDLHelper
.
store
(
tr
,
true
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
...
...
plugins/org.etsi.mts.tdl.standalone/src/org/etsi/mts/tdl/standalone/Standalone.java
View file @
c345caf4
...
...
@@ -301,7 +301,7 @@ public class Standalone {
try
{
Resource
target
=
TDLHelper
.
create
(
resource
.
getURI
().
path
()
+
"."
+
targetExtension
);
target
.
getContents
().
addAll
(
EcoreUtil
.
copyAll
(
resource
.
getContents
()));
TDLHelper
.
store
(
target
);
TDLHelper
.
store
(
target
,
true
);
}
catch
(
Exception
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
...
...
@@ -314,7 +314,7 @@ public class Standalone {
translator
.
setTargetResource
(
TDLHelper
.
create
(
source
.
getAbsolutePath
()+
"-generated."
+
targetExtension
));
translator
.
initTargetResource
(
translator
.
cleanName
(
source
.
getName
()));
translator
.
translate
(
source
.
getAbsolutePath
());
TDLHelper
.
store
(
translator
.
getTargetResource
());
TDLHelper
.
store
(
translator
.
getTargetResource
()
,
true
);
}
catch
(
Exception
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
...
...
plugins/org.etsi.mts.tdl.to2tdl/src/org/etsi/mts/tdl/to2tdl/TO2TDLTranslator.java
View file @
c345caf4
...
...
@@ -475,6 +475,6 @@ public class TO2TDLTranslator extends AbstractTranslator {
initTargetResource
(
"generated_from_"
+
p
.
getName
());
addImports
(
p
);
transform
(
p
);
TDLHelper
.
store
(
tr
);
TDLHelper
.
store
(
tr
,
false
);
}
}
plugins/org.etsi.mts.tdl.yang2tdl/src/org/etsi/mts/tdl/yang2tdl/YANGConverter.java
View file @
c345caf4
...
...
@@ -47,7 +47,7 @@ public class YANGConverter {
// names.add(e.getName());
// }
content
=
TDLHelper
.
getText
(
tr
);
TDLHelper
.
store
(
tr
);
TDLHelper
.
store
(
tr
,
true
);
// Resource tdl = TDLHelper.load(outputPath+".tdl");
// Resource tdltx = TDLHelper.create(outputPath);
// tdltx.getContents().addAll(EcoreUtil.copyAll(tdl.getContents()));
...
...
Prev
1
2
3
Next