Copyright (c) 2013 Lorenz Lehmann
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Sof...
If you think the Android project sodf listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package lal.apps.smartfoodenvironment.model;
/*www.java2s.com*/import java.util.LinkedList;
import java.util.List;
import lal.sodf.framework.ontology.KeyValueNode;
import lal.sodf.framework.ontology.Node;
import lal.sodf.framework.ontology.SodfTree;
/**
* Creates SODF descriptions of products
* @author Lorenz Lehmann
*
*/publicclass ProductFactory {
/** Get the Sodf description for a bottle of milk */publicstatic SodfTree getMilk(){
SodfTree data = new SodfTree();
//add the required metadata
addProductMetadata(data);
data.getPropertiesSubtree().addChild(new KeyValueNode(ProductVocabulary.PRODUCT_NAME, "Milk"));
data.getPropertiesSubtree().addChild(new KeyValueNode(ProductVocabulary.PRODUCT_GOOD_AFTER_OPENING, "2"));
return data;
}
/** Get the Sodf description for a glass of Nutella */publicstatic SodfTree getNutella(){
SodfTree data = new SodfTree();
//add the required metadata
addProductMetadata(data);
data.getPropertiesSubtree().addChild(new KeyValueNode(ProductVocabulary.PRODUCT_NAME, "Nutella"));
data.getPropertiesSubtree().addChild(new KeyValueNode(ProductVocabulary.PRODUCT_GOOD_AFTER_OPENING, "30"));
return data;
}
/** Get the Sodf description for a bag of popcorn */publicstatic SodfTree getPopcorn(){
SodfTree data = new SodfTree();
//add the required metadata
addProductMetadata(data);
addMicrowaveMetadata(data);
//add the properties
data.getPropertiesSubtree().addChild(new KeyValueNode(ProductVocabulary.PRODUCT_NAME, "Popcorn"));
data.getPropertiesSubtree().addChild(new KeyValueNode(ProductVocabulary.PRODUCT_GOOD_AFTER_OPENING, "1"));
//add the microwave function
List<Node> interactions = new LinkedList<Node>();
interactions.add(new KeyValueNode(MicrowaveVocabulary.MICROWAVE_DURATION, "3"));
interactions.add(new KeyValueNode(MicrowaveVocabulary.MICROWAVE_HEAT, "800"));
data.getFunctionsSubtree().addNewFunction(MicrowaveVocabulary.MICROWVAE_PREPARE, interactions);
return data;
}
/** Get the Sodf description for a box of noodles */publicstatic SodfTree getNoodles(){
SodfTree data = new SodfTree();
//add the required metadata
addProductMetadata(data);
addMicrowaveMetadata(data);
//add the properties
data.getPropertiesSubtree().addChild(new KeyValueNode(ProductVocabulary.PRODUCT_NAME, "Noodles"));
data.getPropertiesSubtree().addChild(new KeyValueNode(ProductVocabulary.PRODUCT_GOOD_AFTER_OPENING, "4"));
//add the microwave function
List<Node> interactions = new LinkedList<Node>();
interactions.add(new KeyValueNode(MicrowaveVocabulary.MICROWAVE_DURATION, "8"));
interactions.add(new KeyValueNode(MicrowaveVocabulary.MICROWAVE_HEAT, "1200"));
data.getFunctionsSubtree().addNewFunction(MicrowaveVocabulary.MICROWVAE_PREPARE, interactions);
return data;
}
/** Add the product metadata to a SODF tree */privatestatic SodfTree addProductMetadata(SodfTree data){
data.getMetadataSubtree().getPrefixesSubtree().addChild(
new KeyValueNode(ProductVocabulary.PRODUCT_PREFIX,
ProductVocabulary.PRODUCT_URL));
return data;
}
/** Add the microwave metadata to a SODF tree */privatestatic SodfTree addMicrowaveMetadata(SodfTree data){
data.getMetadataSubtree().getPrefixesSubtree().addChild(
new KeyValueNode(MicrowaveVocabulary.MICROWAVE_PREFIX,
MicrowaveVocabulary.MICROWAVE_PREFIX));
return data;
}
}