Skip to content

Commit

Permalink
updating comments
Browse files Browse the repository at this point in the history
  • Loading branch information
omarrana committed Aug 31, 2017
2 parents 212462b + 58b63b6 commit 5fae171
Show file tree
Hide file tree
Showing 10 changed files with 421 additions and 368 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,16 @@ aml:conf
uri:path "C:/HeterogeneityExampleData/AutomationML/Single-Heterogeneity/M2/Testbeds-2/";
uri:experimentFolder "E:/ExperimentsToKCAP/Experiment1/run -1/";
sto:Standard "aml";
ontosec:Training "false";
ontosec:Training "false";
uri:NegativeRules "true";
uri:URI "C:/Experiments/SemCPS-/resources/".
```
Please note:
```
uri:path refers to Heterogeneity path
uri:URI refers to the ontology path
uri:URI refers to the ontology path
Negative rules true to user orignal.
false to use emulation.
```

Just give path of AML heterogenity and folders will be created automatically.
Expand Down
30 changes: 26 additions & 4 deletions src/main/java/industryStandard/AML.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ public void addsDataforAML() throws FileNotFoundException {

}

/**
* This function checks if the attribute type is of eclass. Adds notation
* :remove marking it as literal value.
*/
private void eClassCheck() {
/***
* Eclass part starts here. TODO refactoring and functions only for test
* purpose now
*/
if (object.isLiteral()) {
if (checkEclass(object)) {
StmtIterator stmts = model.listStatements(subject.asResource(), null,
Expand Down Expand Up @@ -108,6 +108,9 @@ private void eClassCheck() {
}
}

/**
* This function populates all data for Elements with ID.
*/
private void hasIdentifier() {
// RefSemantic part starts here

Expand All @@ -118,6 +121,9 @@ private void hasIdentifier() {
}
}

/**
* This function populates all data with Attribute.
*/
private void hasAttribute() {
if (predicate.asNode().getLocalName().equals("hasAttribute")) {
// gets all classes which hasAttribute relation
Expand All @@ -126,6 +132,10 @@ private void hasAttribute() {
}
}

/**
* This function populates all data with Attribute Value.
*/

private void hasAttributeValue() {
if (predicate.asNode().getLocalName().equals("hasAttributeValue")) {
if (!checkEclass(object)) {
Expand All @@ -136,6 +146,10 @@ private void hasAttributeValue() {

}

/**
* This function populates with type of Element.
*/

private void addHasType() {
if (predicate.asNode().getLocalName().equals("type")) {
if (number != 3)
Expand All @@ -145,6 +159,10 @@ private void addHasType() {

}

/**
* This function adds Domain and Rage.
*/

private void addDomainRange() {
// Adds domain and range
if (predicate.asNode().getLocalName().equals("domain")
Expand All @@ -161,6 +179,10 @@ private void addDomainRange() {
}
}

/**
* This function populates all data with AttributeName.
*/

private void hasAttributeName() {
if (predicate.asNode().getLocalName().equals("hasAttributeName")) {
if (!checkEclass(object)) {
Expand Down
95 changes: 52 additions & 43 deletions src/main/java/industryStandard/IndustryStandards.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
import com.hp.hpl.jena.rdf.model.StmtIterator;

/**
* This class contains common methods to produce the conversion of Industry 4.0 standards
* information models to a canonical model, i.e., RDF
* This class contains common methods to produce the conversion of Industry 4.0
* standards information models to a canonical model, i.e., RDF
*
* @author omar
*/

Expand All @@ -29,8 +30,6 @@ public class IndustryStandards {
public RDFNode object;
int number;



public IndustryStandards() {
super();
}
Expand All @@ -41,8 +40,9 @@ public IndustryStandards(Model newModel, int newNumber) {
}

/**
* add subjects with appropriate ontology All the data is added into generic
* Hash map with a key identifying to what it belongs.
* This function add subjects with appropriate ontology. All the data is
* added into generic data structure. The data structure HashMap allows us
* to have 1 key with many values.
*
* @param subject
* @param subjects
Expand Down Expand Up @@ -81,9 +81,9 @@ protected void addSubjectURI(RDFNode subject, String predicate, int number, Stri
}
}
}

/**
* Gets the class of object.
* This function gets the type of Element.
*
* @param name
* @return
Expand All @@ -100,9 +100,10 @@ String getType(RDFNode name) {
}
return type;
}

/**
* get predicate Value
* This function gets predicate value.
*
* @param name
* @return
*/
Expand All @@ -118,60 +119,68 @@ String getValue(RDFNode name, String predicate) {
}
return type;
}

/**
* TODO to write comment
* This function takes two predicate which are interlinked with each other.
* It connects two predicates e.g Attribute has RefSemantic , RefSemantic
* has Corresponding Path.
*
* @param firstPredicate
* @param secondPredicate
* @throws FileNotFoundException
*/
public void addGenericObject(String firstPredicate, String secondPredicate )
throws FileNotFoundException{
public void addGenericObject(String firstPredicate, String secondPredicate)
throws FileNotFoundException {
if (predicate.asNode().getLocalName().equals(firstPredicate)) {
// adds for attribute
addSubjectURI(subject, ":" + object.asNode().getLocalName(), number,
"has" + getType(subject));
// adds for refsemantic.txt
addGenericValue(predicate.asNode().getLocalName(),secondPredicate);
addGenericValue(predicate.asNode().getLocalName(), secondPredicate);
}
}

/**
* Add refSemantic in the list
* This function adds Elements with literal Value.
*
* @param type
* @param predicate
* @throws FileNotFoundException
*/
private void addGenericValue(String type, String predicate) throws FileNotFoundException {
StmtIterator stmts = model.listStatements(object.asResource(), null, (RDFNode) null);
while (stmts.hasNext()) {
Statement stmte = stmts.nextStatement();
if(stmte.getPredicate().getLocalName().equals(predicate)){
if (stmte.getPredicate().getLocalName().equals(predicate)) {
if (stmte.getObject().isLiteral()) {
addSubjectURI(object, ":remove" + stmte.getObject().asLiteral().getLexicalForm(),
number, type);
addSubjectURI(object,
":remove" + stmte.getObject().asLiteral().getLexicalForm(), number,
type);
}
}
}
}

/**
* Adds AML Values
* This function converts Object into Values reading from Rdf files. The
* values are stored in list.
*
* @param amlList
* @param amlValue
* @param aml
* @return
*/
protected ArrayList<String> addAmlValues(ArrayList<?> amlList,ArrayList<String> amlValue,String aml,
String predicate){
for(int i = 0;i < amlList.size();i++){
protected ArrayList<String> addAmlValues(ArrayList<?> amlList, ArrayList<String> amlValue,
String aml, String predicate) {
for (int i = 0; i < amlList.size(); i++) {
StmtIterator iterator = model.listStatements();
while (iterator.hasNext()) {
Statement stmt = iterator.nextStatement();
subject = stmt.getSubject();

if(subject.asResource().getLocalName().equals(amlList.get(i))){
String value = getValue(subject, predicate);
if(value != null){
if (subject.asResource().getLocalName().equals(amlList.get(i))) {
String value = getValue(subject, predicate);
if (value != null) {
amlValue.add(aml + value);
break;
}
Expand All @@ -180,30 +189,32 @@ protected ArrayList<String> addAmlValues(ArrayList<?> amlList,ArrayList<String>
}
return amlValue;
}

/**
* Adds aml negative Values
*
* @param amlList
* @param amlValue
* @param aml
* @return
*/
protected HashMap<String, String> addAmlNegValues(ArrayList<?> amlList,HashMap<String, String> amlValue,String aml,
String predicate,ArrayList<?> type,HashMap<String, String>pred){
for(int i = 0;i < amlList.size();i++){
protected HashMap<String, String> addAmlNegValues(ArrayList<?> amlList,
HashMap<String, String> amlValue, String aml, String predicate, ArrayList<?> type,
HashMap<String, String> pred) {
for (int i = 0; i < amlList.size(); i++) {
StmtIterator iterator = model.listStatements();
while (iterator.hasNext()) {
Statement stmt = iterator.nextStatement();
subject = stmt.getSubject();
if(subject.asResource().getLocalName().equals(amlList.get(i))){
String value = getValue(subject,predicate);
if(value != null && !value.contains("eClassIRDI")
&&!value.contains("eClassClassificationClass")
&&!value.contains("eClassVersion")){
amlValue.put(aml + value,type.get(i).toString());
pred.put(aml + value,predicate);

if (subject.asResource().getLocalName().equals(amlList.get(i))) {
String value = getValue(subject, predicate);
if (value != null && !value.contains("eClassIRDI")
&& !value.contains("eClassClassificationClass")
&& !value.contains("eClassVersion")) {
amlValue.put(aml + value, type.get(i).toString());
pred.put(aml + value, predicate);

iterator.close();
break;
}
Expand All @@ -213,6 +224,4 @@ protected HashMap<String, String> addAmlNegValues(ArrayList<?> amlList,HashMap<S
return amlValue;
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@

/**
* @author omar
*
* TODO to write comments
*/
public class XmlParser {
public class XMLParser {

private static XPathFactory xpf;
private static XPath xpath;
Expand All @@ -44,7 +44,7 @@ public class XmlParser {
/*
* Constructor initializes
*/
public XmlParser() {
public XMLParser() {
integrationNodes = new ArrayList<Node>();
seedNodes = new ArrayList<Node>();
xpf = XPathFactory.newInstance();
Expand Down Expand Up @@ -459,7 +459,6 @@ void finalizeIntegration(Document integration, String file) throws TransformerFa
* @param integration
* @throws XPathExpressionException
*/

void setNodeValues(Document seed, Document integration) throws XPathExpressionException {
seedNodes = new ArrayList<Node>();

Expand All @@ -482,7 +481,6 @@ void setNodeValues(Document seed, Document integration) throws XPathExpressionEx
* @param doc
* @return
*/

public static ArrayList<Node> getAllNodes(Document doc) {

ArrayList<Node> node = new ArrayList<Node>();
Expand Down
Loading

0 comments on commit 5fae171

Please sign in to comment.