Permalink
Browse files

schema and grammar tidying up

  • Loading branch information...
1 parent da879b7 commit a100a4ddabccdc0d38015fef51e0b58bdd7969cb @lucmoreau lucmoreau committed Mar 20, 2012
@@ -107,8 +107,8 @@ entityExpression
activityExpression
- : 'activity' '(' identifier (',' (startTime | '-' ) ',' (endTime | '-'))? optionalAttributeValuePairs ')'
- -> ^(ACTIVITY identifier ^(START startTime?) ^(END endTime?) optionalAttributeValuePairs )
+ : 'activity' '(' identifier (',' (s=time | '-' ) ',' (e=time | '-'))? optionalAttributeValuePairs ')'
+ -> ^(ACTIVITY identifier ^(START $s?) ^(END $e?) optionalAttributeValuePairs )
;
generationExpression
@@ -134,14 +134,16 @@ endExpression
-> ^(WEB ^(ID $id0?) $id2 $id1 ^(TIME time?) optionalAttributeValuePairs)
;
+/* TODO: write traversers */
+
informExpression
- : 'wasInformedBy' '(' optionalIdentifier identifier ',' identifier optionalAttributeValuePairs ')'
- -> ^(WIB optionalIdentifier identifier+ optionalAttributeValuePairs)
+ : 'wasInformedBy' '(' ((id0=identifier | '-') ',')? id2=identifier ',' id1=identifier optionalAttributeValuePairs ')'
+ -> ^(WIB ^(ID $id0?) $id2 $id1 optionalAttributeValuePairs)
;
wasStartedByActivityExpression
- : 'wasStartedByActivity' '(' optionalIdentifier identifier ',' identifier optionalAttributeValuePairs ')'
- -> ^(WSBA optionalIdentifier identifier+ optionalAttributeValuePairs)
+ : 'wasStartedByActivity' '(' ((id0=identifier | '-') ',')? id2=identifier ',' id1=identifier optionalAttributeValuePairs ')'
+ -> ^(WSBA ^(ID $id0?) $id2 $id1 optionalAttributeValuePairs)
;
@@ -274,12 +276,6 @@ optionalAttributeValuePairs
-> ^(ATTRIBUTES attributeValuePairs?)
;
-optionalTime
- :
- (',' time )?
- -> ^(TIME time?)
- ;
-
optionalIdentifier
:
(identifier ',')?
@@ -314,19 +310,6 @@ time
:
xsdDateTime
;
-startTime
- :
- xsdDateTime
- ;
-endTime
- :
- xsdDateTime
- ;
-
-recipeLink
- :
- IRI_REF
- ;
/* TODO: complete grammar of Literal */
literal
@@ -391,12 +374,6 @@ NCNAME_COLON_STAR
STAR_COLON_NCNAME
: '*' ':' NCNAME;
-/*
-NUMERICLITERAL
- : ( ('.' DIGITS) |(DIGITS ('.' ('0'..'9')*)?)) (('e'|'E') ('+'|'-')? DIGITS)?
- ;
-
-*/
fragment QUOTE
: '"'
;
@@ -499,7 +476,6 @@ xsdDateTime: IsoDateTime;
-
IsoDateTime: (DIGIT DIGIT DIGIT DIGIT '-' DIGIT DIGIT '-' DIGIT DIGIT 'T' DIGIT DIGIT ':' DIGIT DIGIT ':' DIGIT DIGIT ('.' DIGIT (DIGIT DIGIT?)?)? ('Z' | TimeZoneOffset)?)
;
@@ -12,7 +12,6 @@
import org.openprovenance.prov.xml.Used;
import org.openprovenance.prov.xml.WasAssociatedWith;
import org.openprovenance.prov.xml.AlternateOf;
-import org.openprovenance.prov.xml.WasControlledBy;
import org.openprovenance.prov.xml.WasDerivedFrom;
import org.openprovenance.prov.xml.WasGeneratedBy;
import org.openprovenance.prov.xml.WasInformedBy;
@@ -3,6 +3,7 @@ container
prefix ex <http://example>
activity(ex:a1, [ex:param="a"])
+ activity(ex:a2, [ex:param="a"])
entity(ex:e1, [ex:param="a"])
entity(ex:e2, [ex:param="a"])
agent(ex:ag1, [ex:param="a"])
@@ -285,5 +286,7 @@ prefix ex <http://example>
hasAnnotation(ex:e1, ex:n1)
hasAnnotation(ex:n1, ex:n1)
+ wasInformedBy(ex:a1, ex:a2)
+ wasStartedByActivity(ex:a1, ex:a2)
endContainer
View
@@ -258,12 +258,6 @@
</exec>
<exec executable="sed" dir="${project.build.directory}/generated-sources/xjc/org/openprovenance/prov/xml">
- <arg value="-e s/implements Equals, HashCode, ToString/implements Relation, HasRole, HasType, Equals, HashCode, ToString/" />
- <arg value="-iBAK" />
- <arg value="WasControlledBy.java" />
- </exec>
-
- <exec executable="sed" dir="${project.build.directory}/generated-sources/xjc/org/openprovenance/prov/xml">
<arg value="-e s/implements Equals, HashCode, ToString/implements Relation0, Equals, HashCode, ToString/" />
<arg value="-iBAK" />
<arg value="AlternateOf.java" />
@@ -27,7 +27,7 @@ public Object convert(Container cont) {
for (Agent ag: cont.getRecords().getAgent() ) {
agRecords.add(convert(ag));
}
- for (Object lnk: cont.getRecords().getDependencies().getUsedOrWasGeneratedByOrWasInformedBy() ) {
+ for (Object lnk: cont.getRecords().getDependencies().getUsedOrWasGeneratedByOrWasStartedBy() ) {
Object o=convertRelation(lnk);
if (o!=null) lnkRecords.add(o);
}
@@ -138,8 +138,6 @@ public Object convertRelation(Object o) {
return convert((Used) o);
} else if (o instanceof WasDerivedFrom) {
return convert((WasDerivedFrom) o);
- } else if (o instanceof WasControlledBy) {
- return convert((WasControlledBy) o);
} else if (o instanceof HasAnnotation) {
return convert((HasAnnotation) o);
} else if (o instanceof WasInformedBy) {
@@ -162,8 +160,8 @@ public Object convert(WasAssociatedWith o) {
tAttrs,
otherAttrs,
c.convert(o.getActivity().getRef()),
- c.convert(o.getAgent().getRef()),
- c.convert(o.getPlan().getRef()));
+ (o.getAgent()==null)? null: c.convert(o.getAgent().getRef()),
+ (o.getPlan()==null)? null: c.convert(o.getPlan().getRef()));
}
public Object convert(Used o) {
@@ -184,10 +182,6 @@ public Object convert(WasDerivedFrom o) {
c.convert(o.getUsedEntity().getRef()));
}
- public Object convert(WasControlledBy o) {
- return null;
- }
-
public Object convert(HasAnnotation o) {
List tAttrs=null;
List otherAttrs=convertAttributes((HasExtensibility)o);
@@ -28,13 +28,6 @@ public static String printURI(java.net.URI u) {
return u.toString();
}
- public static String roleIdPrefix="r_";
- public static String usedIdPrefix="u_";
- public static String wasGenerateByIdPrefix="g_";
- public static String wasDerivedFromIdPrefix="d_";
- public static String wasTriggeredByIdPrefix="t_";
- public static String wasControlledByIdPrefix="c_";
- public static String containerIdPrefix="gr_";
public static final String packageList=
"org.openprovenance.prov.xml";
@@ -198,11 +191,6 @@ public DependencyRef newDependencyRef(WasDerivedFrom edge) {
return res;
}
- public DependencyRef newDependencyRef(WasControlledBy edge) {
- DependencyRef res=of.createDependencyRef();
- res.setRef(edge.getId());
- return res;
- }
public DependencyRef newDependencyRef(WasInformedBy edge) {
DependencyRef res=of.createDependencyRef();
res.setRef(edge.getId());
@@ -352,7 +340,7 @@ public Used newUsed(String id,
String role,
EntityRef aid) {
Used res=of.createUsed();
- res.setId(stringToQName(autoGenerateId(usedIdPrefix,id)));
+ res.setId(stringToQName(id));
res.setActivity(pid);
addRole(res,role);
res.setEntity(aid);
@@ -409,6 +397,19 @@ public WasAssociatedWith newWasAssociatedWith(QName id,
}
+ public WasAssociatedWith newWasAssociatedWith(String id,
+ Activity eid2,
+ Agent eid1) {
+ return newWasAssociatedWith(id,newActivityRef(eid2.getId()),newAgentRef(eid1.getId()));
+ }
+
+ public WasAssociatedWith newWasAssociatedWith(QName id,
+ Activity eid2,
+ Agent eid1) {
+ return newWasAssociatedWith(id,newActivityRef(eid2.getId()),newAgentRef(eid1.getId()));
+ }
+
+
public ActedOnBehalfOf newActedOnBehalfOf(String id,
AgentRef subordinate,
@@ -574,15 +575,6 @@ public Used newUsed(Used u) {
return u1;
}
- public WasControlledBy newWasControlledBy(WasControlledBy c) {
- WasControlledBy wcb=newWasControlledBy(c.getEffect(),
- null,
- c.getCause());
- wcb.setId(c.getId());
- wcb.getAny().addAll(c.getAny());
- return wcb;
- }
-
public WasGeneratedBy newWasGeneratedBy(WasGeneratedBy g) {
WasGeneratedBy wgb=newWasGeneratedBy(g.getId(),
g.getEntity(),
@@ -720,30 +712,6 @@ public WasGeneratedBy newWasGeneratedBy(String id,
return wgb;
}
- public WasControlledBy newWasControlledBy(ActivityRef pid,
- String role,
- AgentRef agid) {
- return newWasControlledBy((QName)null,pid,role,agid);
- }
-
- public WasControlledBy newWasControlledBy(QName id,
- ActivityRef pid,
- String role,
- AgentRef agid) {
- WasControlledBy res=of.createWasControlledBy();
- res.setId(id);
- res.setEffect(pid);
- res.setCause(agid);
- addRole(res,role);
- return res;
- }
- public WasControlledBy newWasControlledBy(String id,
- ActivityRef pid,
- String role,
- AgentRef agid) {
- return newWasControlledBy(stringToQName(id),pid,role,agid);
- }
-
public HasAnnotation newHasAnnotation(Identifiable i,
Note n) {
@@ -769,31 +737,6 @@ public HasAnnotation newHasAnnotation(String n1,
return res;
}
- public WasControlledBy newWasControlledBy(Activity p,
- String role,
- Agent ag) {
- return newWasControlledBy(null,p,role,ag);
- }
-
- public WasControlledBy newWasControlledBy(String id,
- Activity p,
- String role,
- Agent ag) {
- AgentRef agid=newAgentRef(ag);
- ActivityRef pid=newActivityRef(p);
- return newWasControlledBy(id,pid,role,agid);
- }
-
- public WasControlledBy newWasControlledBy(String id,
- Activity p,
- String role,
- Agent ag,
- String type) {
- WasControlledBy wcb=newWasControlledBy(id,p,role,ag);
- addType(wcb,type);
- return wcb;
- }
-
public WasDerivedFrom newWasDerivedFrom(QName id,
EntityRef aid1,
@@ -1074,7 +1017,7 @@ public Container newContainer(QName id,
}
if (lks!=null) {
Dependencies ccls=of.createDependencies();
- ccls.getUsedOrWasGeneratedByOrWasInformedBy().addAll(lks);
+ ccls.getUsedOrWasGeneratedByOrWasStartedBy().addAll(lks);
res.getRecords().setDependencies(ccls);
}
@@ -20,7 +20,7 @@
public List<Relation0> getRelations(Container g) {
List<Relation0> res=new LinkedList();
Dependencies dep=g.getRecords().getDependencies();
- for (Object o:dep.getUsedOrWasGeneratedByOrWasInformedBy()) {
+ for (Object o:dep.getUsedOrWasGeneratedByOrWasStartedBy()) {
System.out.println("relation is " + o);
res.add((Relation0)o);
}
@@ -37,9 +37,6 @@ public QName getEffect(Relation0 r) {
if (r instanceof WasDerivedFrom) {
return ((WasDerivedFrom)r).getGeneratedEntity().getRef();
}
- if (r instanceof WasControlledBy) {
- return ((WasControlledBy)r).getEffect().getRef();
- }
if (r instanceof WasAssociatedWith) {
return ((WasAssociatedWith)r).getActivity().getRef();
}
@@ -63,10 +60,7 @@ public QName getCause(Relation0 r) {
if (r instanceof WasDerivedFrom) {
return ((WasDerivedFrom)r).getUsedEntity().getRef();
}
- if (r instanceof WasControlledBy) {
- return ((WasControlledBy)r).getCause().getRef();
- }
- if (r instanceof WasAssociatedWith) { // what about entity plan?
+ if (r instanceof WasAssociatedWith) {
return ((WasAssociatedWith)r).getAgent().getRef();
}
if (r instanceof AlternateOf) {
Oops, something went wrong.

0 comments on commit a100a4d

Please sign in to comment.