package org.wontovlab.tool;

import java.util.HashMap;
import java.util.List;

import org.wontovlab.model.Experiment;
import org.wontovlab.model.Material;
import org.wontovlab.model.Property;
import org.wontovlab.model.Step;
import org.wontovlab.model.Task;

public class WPF {

	private OntologyMethodsBean ontologyMethodsCoreBean;
	private XPDLParserBean xpdlParserBean; 
	
	
	/* 
	 * starts the class with the following params:
	 * @param isOWLFileSavedLocally If the owl file will be accessed in the local drive, set true, otherwise, if the file will be accessed in a web address, set this param false
	 * @param doOwlPath Path to the domain ontology OWL file. This must be like this: c:\\progr~1\\Test\\File.owl or /usr/local/ontology/file.owl or http://url/owlfile.owl
	 * @param doDocURI	Domain Ontology URI
	 * @param aoOwlPath Path to the application ontology OWL file. This must be like this: c:\\progr~1\\Test\\File.owl or /usr/local/ontology/file.owl or http://url/owlfile.owl
	 * @param aoDocURI	Application Ontology URI
	 */
	public WPF(boolean isOWLFileSavedLocally, String doOwlPath, String doDocURI, String aoOwlPath, String aoDocURI) {
		ontologyMethodsCoreBean = OntologyMethodsBean.getInstance(isOWLFileSavedLocally, doOwlPath, doDocURI, aoOwlPath, aoDocURI);
		
		xpdlParserBean = new XPDLParserBean();
	}
	
	
////////////////////////////////////////////////////////////////////////////////	

	/*
	 * Return all materials from Domain Ontology 
	 */
	public List<Material> doGetAllMaterials() {
		return ontologyMethodsCoreBean.doGetAllMaterials();
	}

	/*
	 * This method returns a Material object from a domain ontology URI
	 */
	public Material doGetMaterial(String domainOntologyMaterialReference) {
		return ontologyMethodsCoreBean.doGetMaterial(domainOntologyMaterialReference);
	}

	/*
	 * @ param material Material object which the user wants to get similar materials
	 * This method returns a Material object list which have materials similar to the material passed as parameter.    
	 */
	public List<Material> doGetInstancesSimilarTo(Material material) {
		return ontologyMethodsCoreBean.doGetInstancesSimilarTo(material);
	}

////////////////////////////////////////////////////////////////////////////////	
	
	/*
	 * Return all tasks from Application Ontology 
	 */
	public List<Task> aoGetAllTasks() {
		return ontologyMethodsCoreBean.aoGetAllTasks();
	}
	
	/*
	 * @param task The application ontology task. It will be used to get the task's application ontology URI 
	 * This method returns a Material object list of all materials used in the task passed as parameter 
	 */
	protected List<Material> aoGetTaskMaterials(String applicationOntologyTaskURI) {
		return ontologyMethodsCoreBean.aoGetTaskMaterials(applicationOntologyTaskURI);
	}
	
	public Task aoGetTask(String ontoInstanceReference) {
		return ontologyMethodsCoreBean.getInstance().aoGetTask(ontoInstanceReference);
	}
	
	/*
	 * @param applicationOntologyTaskURI The application ontology step URI
	 * This method get the param applicationOntologyTaskURI and verify over the application ontology if there are alternative
	 * steps for this step. If there is, it will return a list of Step.
	 */
	protected List<Task> aoGetTasksSimilarTo(String applicationOntologyTaskReference) {
		return ontologyMethodsCoreBean.aoGetTasksSimilarTo(applicationOntologyTaskReference);
	}
	
	
	
	
	
/*	
	 * List all instanced attributes from a individual.
	 * @param ontoInstanceReference	Ontology instance full name	
	 
	public List<Property> listIndividualInstancedAttributes(String ontoInstanceReference) {
		return ontologyMethodsCoreBean.listIndividualInstancedAttributes(ontoInstanceReference);
	}*/

	
	
	

	
	/*
	 * Read the authorship XPDL workflow from a file. Before use any method to handle the workflow, it is necessary to read it through this method.
	 */
	public Experiment readAuthorshipXPDL(String xpdlPath) throws Exception {
		return xpdlParserBean.readAuthorshipXPDL(xpdlPath);
	}
	
	/*
	 * Read the execution XPDL workflow from a file. Before use any method to handle the workflow, it is necessary to read it through this method.
	 */
	public Experiment readExecutionXPDL(String xpdlPath) throws Exception {
		return xpdlParserBean.readExecutionXPDL(xpdlPath);
	}

	/*
	 * Comparing the authorship and execution workflows 
	 */
	public String comparingWorkflows() throws Exception{
		return xpdlParserBean.comparingWorkflows();
	}

	
	/*
	 * It creates the XPDL authorship workflow string and save it on the hard disk
	 * @param experiment The experiment object which will be read and written in a XPDL file 
	 * @param xpdlFilePath Path where the XPDL file will be created (on the file system)
	 */
	public void creatingAuthorshipWorkflow(Experiment experiment, String xpdlFilePath) {
		xpdlParserBean.creatingAuthorshipWorkflow(experiment, xpdlFilePath);
	}
	
	/*
	 * It creates the XPDL execution workflow string and save it on the hard disk
	 * @param experiment The experiment object which will be read and written in a XPDL file 
	 * @param xpdlFilePath Path where the XPDL file will be created (on the file system)
	 */
	public void creatingExecutionWorkflow(Experiment experiment, String xpdlFilePath) {
		xpdlParserBean.creatingExecutionWorkflow(experiment, xpdlFilePath);
	}
	
	



}
