/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.metrapp.api;
import java.io.File;
import org.metrapp.dataModel.DataFrame;
import org.metrapp.dataModel.StringDataFrame;
import org.metrapp.filters.Filter;
import org.metrapp.io.Loader;
import org.metrapp.sys.Controller;
import rcaller.RCaller;
import rcaller.RCode;
/**
*
* @author Ilija
*/
public class Facade {
private Loader loader;
private RCaller caller;
private RCode code;
public Facade(){
loader = new Loader();
caller = new RCaller();
code = new RCode();
}
//AT THIS POINT ZHR AND POPULATION INDEX FIELDS SHOULD BE IMPLEMENTED; WAITING FOR R CODE, THIS FACADE WILL LOAD DATA FROM GIVEN LOCATION AND APPLY FILTER WHICH USER HAS SELECTED
public boolean executeClientRequest (String fileLocation, Filter filterFromClient){
Controller.getInstance().initializeBasic(caller, code);
loader.loadFile(fileLocation, caller, code);
File xmlDocument = caller.getParser().getXMLFile();
DataFrame df = new StringDataFrame();
df.createDataFrameAndFillItWithData(xmlDocument);
Controller.getInstance().updateDataFrame(df);
Filter filter = filterFromClient;
filter.filterData(df, caller, code, null);
//RESULT SHOULD BE PASSED TO CLIENT AS XML
return true;
}
}