Commit e883186a authored by Jay Jay Billings's avatar Jay Jay Billings
Browse files

Finished ICEModelFactory basic implementation.



Made a basic implementation of ICEModelFactory, which is the new name
for ModelFactory. I made the name change so that it would not collide
with Apache Jena's ModelFactory. Also committed a basic test for it that
checks for null values returned by the factory methods. Finally, I
removed the unused AppTest class.
Signed-off-by: default avatarJay Jay Billings <billingsjj@ornl.gov>
parent 34e3ceb2
......@@ -11,53 +11,55 @@
*****************************************************************************/
package org.eclipse.ice.data;
import org.apache.jena.ontology.OntModel;
import org.apache.jena.ontology.OntModelSpec;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.Resource;
import org.apache.jena.rdf.model.ModelFactory;
import org.apache.jena.util.FileManager;
/**
* The ModelFactory class is responsible for creating ICE RDF models and
* associated resources.
* associated resources. It is the basic abstract factory from which all ICE
* data structures can be built.
*
* @author Jay Jay Billings
*
*/
public class ModelFactory {
public class ICEModelFactory {
/**
* This operation creates a basic ICE data RDF model.
* The ICE ontology
*/
private OntModel iceOntModel;
/**
* Constructor responsible for initializing the entire ICE ontology for the
* factory.
*/
public ICEModelFactory() {
Model baseModel = FileManager.get().loadModel("data/ice-owl.ttl", null, "TURTLE");
// No need for an inferencer... yet.
iceOntModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, baseModel);
}
/**
* This operation creates a basic RDF model for storing ICE data artifacts.
*
* @return the empty RDF model
*/
public Model createModel() {
Model model = null;
Model model = ModelFactory.createDefaultModel();
return model;
}
/**
* This operation returns a builder that can be used to construct a new ICE component.
* This operation returns a builder that can be used to construct a new ICE
* component.
*
* @return the Component Builder for making new components
*/
public ComponentBuilder createComponent() {
return new ComponentBuilder(null);
return new ComponentBuilder(iceOntModel);
}
public Resource createComponent(final int id) {
Resource component = null;
return component;
}
public Resource createComponent(final int id, final String name) {
Resource component = null;
return component;
}
public Resource createComponent(final int id, final String name, final String desc) {
Resource component = null;
return component;
}
public Resource createComponent(final int id, final String name, final String desc, final String context) {
Resource component = null;
return component;
}
}
package org.eclipse.ice.tests.data;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* Unit test for simple App.
*/
public class AppTest extends TestCase {
/**
* Create the test case
*
* @param testName name of the test case
*/
public AppTest(String testName) {
super(testName);
}
/**
* @return the suite of tests being tested
*/
public static Test suite() {
return new TestSuite(AppTest.class);
}
/**
* Rigourous Test :-)
*/
public void testApp() {
assertTrue(true);
}
}
/******************************************************************************
* Copyright (c) 2019- UT-Battelle, LLC.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Initial API and implementation and/or initial documentation -
* Jay Jay Billings
*****************************************************************************/
package org.eclipse.ice.tests.data;
import static org.junit.Assert.*;
import org.apache.jena.rdf.model.Model;
import org.eclipse.ice.data.ComponentBuilder;
import org.eclipse.ice.data.ICEModelFactory;
import org.junit.BeforeClass;
import org.junit.Test;
/**
* This class tests the ModelFactory used to build ICE's data structures.
*
* @author Jay Jay Billings
*
*/
public class ICEModelFactoryTest {
/**
* @throws java.lang.Exception
*/
@BeforeClass
public static void setUpBeforeClass() throws Exception {
}
/**
* Test method for {@link org.eclipse.ice.data.ICEModelFactory#createModel()}.
*/
@Test
public void testCreateModel() {
ICEModelFactory modelFactory = new ICEModelFactory();
Model model = modelFactory.createModel();
assertNotNull(model);
return;
}
/**
* Test method for {@link org.eclipse.ice.data.ICEModelFactory#createComponent()}.
*/
@Test
public void testCreateComponent() {
ICEModelFactory modelFactory = new ICEModelFactory();
ComponentBuilder builder = modelFactory.createComponent();
assertNotNull(builder);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment