Is there a way to transform, using transformation editor (ctr+alt+h), a "class" to a "property of the class" using the Transformation editor in Enterprise Architect?
If i have this design:
Class1-|port1| <----Connector----> |port2|-Class2
i would like;
Property of class 1-|flowport1 from port1| <----Connector----> |flowport2 from port2|-Property of Class2
The current code looks like this (Class):
%if elemType=="Class"%
part
{
%TRANSFORM_CURRENT("Class","stereotype")%
%TRANSFORM_REFERENCE("Class",classGUID)%
name=%qt%%className%%qt%
stereotype = "Block"
%list="InnerClass" #separator="\n" #indent=" "%
}
%elseIf elemType=="Port"%
Port
{
%TRANSFORM_CURRENT("Class","stereotype")%
%TRANSFORM_REFERENCE("Class")%
stereotype = "FlowPort"
%if classStereotype=="inPort"%
Tag
{
%list="InnerClass" #separator="\n" #indent=" "%
name = "direction"
value = "out"
}
%elseIf classStereotype=="OutPort"%
Tag
{
name = "direction"
value = "out"
}
%else%
Tag
{
name = "direction"
value = "inout"
}
%endIf%
%list="Connector" #separator="\n" #indent=" "%
}
%endIf%
The current code takes all the classes from a design and makes new parts with "stereotype: Block". It also takes the design ports (defined as in-/outports) and changes their stereotype to flowports with correct direction.
Hope my explaination is sufficient
Thank you
Related
I have 2 agents of different type.
[Person(type) owner(agent) 1(parameter) Carlink(connection)]
[Vehicle(type) car(agent) 1(parameter) OwnerLink(connection)]
I want to link them if parameter "1" of the owner is same to parameter "1" of the car.
I'm thinking adding this statement on startup on Vehicle(type)
OwnerLink.connectto("condition")
What syntax should I need to add on the "condition" part.
Thanks in advance.
My understanding is that you have two populations: owners and cars. You also have a parameter called 1 in each (which is an int? double?). You also want to create single bidirectional links. If so, your code would be as follows:
for( Person p : owners) {
for( Vehicle v : cars) {
if( p.1 == v.1) {
p.Carlink.connectTo(v);
break;
}
}
}
If you may have multiple links, remove break;, also if you parameter is of type String, replace == v.1 with .equals(v.1).
To place the code in vehicle startup:
for( Person p : owners) {
if( p.1 == 1) {
p.Carlink.connectTo(this);
break;
}
}
}
I am working on Liferay 7. I created a document type "My Documents" with field "Language" which is a selection dropdown with values "English", "French" and "Spanish". I uploaded a document and selected Language value as French. Now I am trying to get this Language value for the document but its returning blank. Below is the code I am using.
DDMStructure ddmStructure = null;
List<DDMStructure> structures = dLFileEntryType.getDDMStructures();
mainloop:
for (DDMStructure struct : structures) {
if (struct.getName((Locale.ROOT)).equalsIgnoreCase("My Document")) {
ddmStructure = struct;
break mainloop;
}
}
DLFileEntryMetadata fileEntryMetadata = null;
try {
fileEntryMetadata = DLFileEntryMetadataLocalServiceUtil.getFileEntryMetadata(ddmStructure.getStructureId(), dlFileEntry.getFileVersion().getFileVersionId());
if(Validator.isNotNull(fileEntryMetadata)) {
ServiceContext serviceContextDLFile = new ServiceContext();
serviceContextDLFile.setCompanyId(companyId);
serviceContextDLFile.setAttribute("fileEntryTypeId", fileEntryTypeId);
serviceContextDLFile.setAttribute("fileEntryMetadataId", fileEntryMetadata.getFileEntryMetadataId());
serviceContextDLFile.setAttribute("DDMStorageId", fileEntryMetadata.getDDMStorageId());
serviceContextDLFile.setAttribute("fileEntryId", fileEntryMetadata.getFileEntryId());
serviceContextDLFile.setAttribute("fileVersionId", fileEntryMetadata.getFileVersionId());
DDMFormValues ddmFormValues = StorageEngineManagerUtil.getDDMFormValues(fileEntryMetadata.getDDMStructureId(), null, serviceContextDLFile);
List<DDMFormFieldValue> ddmFormFieldValues = ddmFormValues.getDDMFormFieldValues();
if(Validator.isNotNull(ddmFormFieldValues) && !ddmFormFieldValues.isEmpty()) {
for(DDMFormFieldValue formfieldValue : ddmFormFieldValues) {
if(formfieldValue.getName().equalsIgnoreCase("Language")) {
String languageRawName = formfieldValue.getValue().getString(Locale.US);
String language = languageRawName.replace("[\"", "").replace("\"]", "");
}
}
}
}
} catch (NoSuchFileEntryMetadataException nsfene) {
// LOGGER.error("ERROR:: ", nsfene);
} catch(PortalException portalException) {
// LOGGER.error("ERROR:: " , portalException);
}
I have not given any predefined value for Language field while creating Document Type. When I am giving any predefined value for Language field, the above code is returning that predefined value.
Please tell if I am missing something or there is any other approach do achieve this.
Stored data in document library documents is not internationalized.
I think you have to always use the default language of the instance.
I am working with owl api 4.0 in eclipse. The ontotlogy is so designed that an individual has properties and every property has inturn sub property as shown in following figure:-
I want to retrieve the main properties i.e canCraw, canBreath, legs and then their sub properties separately. i used following code:-
OWLClass animalCl = datafactory.getOWLClass(IRI.create(myOntologyIRI + "Animal")); // Animal is the Class name
NodeSet<OWLNamedIndividual> animalIndl = reasoner.getInstances(animalCl, false);
for (OWLNamedIndividual animalNamedIndl : animalIndl.getFlattened())
{
line1: Set<OWLDataPropertyAssertionAxiom> animalPropAll= myOntology.getDataPropertyAssertionAxioms(animalNamedIndl);
mainprop: for (OWLDataPropertyAssertionAxiom ax: animalPropAll)
{
System.out.println("the propery retrieved = " + ax.getProperty()) ; // the sub properties are printed out here alongwith main properties
line2: NodeSet<OWLDataProperty> properties = reasoner.getSubDataProperties((OWLDataProperty) ax.getProperty(), false);
subprop: for (OWLDataProperty mysubproperty : properties.getFlattened())
System.out.println("and the sub property is " + mysubproperty); // this is where i expect the sub properties of the properties
}
}
the output of above mentioned code is:-
the property retrieved = <http://localhost:3030/BiOnt.owl#canCrawl> // this is fine
the property retrieved = <http://localhost:3030/BiOnt.owl#crawlWt> // why is this sub property being printed here? (printing from mainprop for loop)
and the sub property is <http://localhost:3030/BiOnt.owl#crawlWt> // this is fine (printing from subprop for loop)
.
.
.
the property retrieved = <http://localhost:3030/BiOnt.owl#legs> // this is fine
the property retrieved = <http://localhost:3030/BiOnt.owl#legsWt> // why is this sub property being printed here?
and the sub property is <http://localhost:3030/BiOnt.owl#legsWt> // this is fine
What am i doing wrong. Thanks in advance.
reasoner.getSubDataProperties((OWLDataProperty) ax.getProperty(), false);
The false parameter means subproperty at any level.
If you switch it to true, the reasoner will provide you with the direct subproperties only. If I understand your requirement correctly, that's what you're looking for.
I am using owl api 4.0 and the following code will give me all the property of individuals belonging to class Animal.
OWLClass animalCl = df.getOWLClass(IRI.create(ontologyIRI + "Animal"));
NodeSet<OWLNamedIndividual> animalIndl = reasoner.getInstances(animalCl, false);
for (OWLNamedIndividual animalNamedIndl : animalIndl.getFlattened())
{
Set<OWLDataPropertyAssertionAxiom> propAll= myontology.getDataPropertyAssertionAxioms(animalNamedIndl);
for (OWLDataPropertyAssertionAxiom ax: propAll)
{
for (OWLLiteral propertyLit : EntitySearcher.getDataPropertyValues(animalNamedIndl, ax.getProperty(), myontolgoy))
System.out.println("The property " + ax.getProperty() + "has value" + propertyLit);
}
}
I have a subproperty "propWt" for every data property. I have used following code:-
NodeSet<OWLDataProperty> properties = reasoner.getSubDataProperties((OWLDataProperty) ax.getProperty(), false);
for (OWLDataProperty mysubproperty : properties.getFlattened())
{
System.out.println("the sub property is " + mysubproperty);
}
instead of
the sub property is <http://localhost:3030/BiOnt.owl#propWt>
i get
the sub property is owl:bottomDataProperty
What is the problem here?
Since you are using a reasoner for the ontology, I assume you want all subproperties, either asserted or inferred.
The reasoner can do the job:
NodeSet<OWLDataProperty> properties = reasoner.getSubDataProperties(property, false);
Hy,
I expanding an existing specman test where some code like this appears:
struct dataset {
!register : int (bits:16);
... other members
}
...
data : list of dataset;
foo : dataset;
gen foo;
foo.register = 0xfe;
... assign other foo members ...
data.push(foo.copy());
is there a way to assign to the members of the struct in one line? like:
foo = { 0xff, ... };
I currently can't think of a direct way of setting all members as you want, but there is a way to initialize variables (I'm not sure if it works on struct members as well). Anyway something like the following may fit for you:
myfunc() is {
var foo : dataset = new dataset with {
.register = 0xff;
.bar = 0xfa;
}
data.push(foo.copy());
}
You can find more information about new with help new struct from the specman prompt.
Hope it helps!
the simple beuty of assigning fields by name is one language feature i've always found usefull , safe to code and readable.
this is how i'd go about it:
struct s {
a : int;
b : string;
c : bit;
};
extend sys {
ex() is {
var s := new s with {.a = 0x0; .b = "zero"; .c = 0;};
};
run() is also {
var s;
gen s keeping {.a == 0x0; .b == "zero"; .c == 0;};
};
};
i even do data.push(new dataset with {.reg = 0xff; bar = 0x0;}); but you may raise the readablity flag if you want.
warning: using unpack() is perfectly correct (see ross's answer), however error prone IMO. i recommend to verify (with code that actually runs) every place you opt to use unpack().
You can directly use the pack and unpack facility of Specman with "physical fields" ( those instance members prefixed with the modifier %).
Example:
define FLOODLES_WIDTH 47;
type floodles_t : uint(bits:FLOODLES_WIDTH);
define FLABNICKERS_WIDTH 28;
type flabnickers_t : uint(bits:FLABNICKERS_WIDTH);
struct foo_s {
%!floodle : floodles_t;
%!flabnicker : flabnickers_t;
};
extend sys {
run() is also {
var f : foo_s = new;
unpack(packing.low,64'hdeadbeefdeadbeef,f);
print f;
unpack(packing.low,64'hacedacedacedaced,f);
print f;
};
setup() is also {
set_config(print,radix,hex);
};
};
When this run, it prints:
Loading /nfs/pdx/home/rbroger1/tmp.e ...
read...parse...update...patch...h code...code...clean...
Doing setup ...
Generating the test using seed 1...
Starting the test ...
Running the test ...
f = foo_s-#0: foo_s of unit: sys
---------------------------------------------- #tmp
0 !%floodle: 0x3eefdeadbeef
1 !%flabnicker: 0x001bd5b
f = foo_s-#0: foo_s of unit: sys
---------------------------------------------- #tmp
0 !%floodle: 0x2cedacedaced
1 !%flabnicker: 0x00159db
Look up packing, unpacking, physical fields, packing.low, packing.high in your Specman docs.
You can still use physical fields even if the struct doesn't map to the DUT. If your struct is already using physical fields for some other purpose then you'll need to pursue some sort of set* method for that struct.