// Path: api/agol-writer/src/main/java/esride/opendatabridge/agolreader/IAgolItemReader.java
// public interface IAgolItemReader {
// 
//     public AgolItem getAgolItemById(String agolId);
// 
//     public List<String> getAgolItemIdByTitle(String title);
// 
//     public List<String> getAgolItemIdByUrl(String url);
// 
//     public String getAgolItemIdByCatalogId(String catalogId);
// 
//     public void touchItem(String agolId);
// 
//     public List<String> getUntouchedAgolItems();
// 
// }
// 
// Path: api/agol-writer/src/main/java/esride/opendatabridge/agolwriter/IAgolService.java
// public interface IAgolService {
// 
// 
//     public void insertItem(AgolItem agolItem, AccessType accessType) throws IOException;
// 
//     public void updateItem(AgolItem agolItem, AccessType accessType, boolean overwriteAccessType) throws IOException;
// 
//     public void deleteItem(String agolId) throws IOException;
// 
//     /**
//      * Wrapper: Create ArcGIS Online Item from HashMap
//      * @param agolItemProperties
//      * @return
//      */
//     AgolItem createAgolItem(HashMap agolItemProperties) throws AgolItemInvalidException;
// 
//     /**
//      * Merge 2 ArcGIS Online Items by copying metadata from source to target and leaving
//      * @param sourceItem
//      * @param targetItem
//      * @return
//      */
//     AgolItem mergeAgolItems(AgolItem sourceItem, AgolItem targetItem);
// }
// 
// Path: api/objectpipeline/src/main/java/esride/opendatabridge/pipeline/controller/PipelineController.java
// public class PipelineController implements IPipeline{
// 
//     private ArrayList<IPipeline> pipelineList;
// 
//     public void setPipelineList(ArrayList<IPipeline> pPipelineList) {
//         pipelineList = pPipelineList;
//     }
// 
//     public void examineAndChangeObject(HashMap<String, String> elements) throws InvalidObjectException {
//         if(pipelineList != null){
//             for(int i=0; i<pipelineList.size(); i++){
//                 pipelineList.get(i).examineAndChangeObject(elements);
//             }
//         }
//     }
// }
// 
// Path: api/catalog-reader/src/main/java/esride/opendatabridge/reader/IReader.java
// public interface IReader {
// 
//     public TransformedItemResult getTramsformedItemsFromCatalog(int startPos) throws ReaderException;
// 
//     public MetadataObjectResult getItemsFromCatalog(int startPos) throws ReaderException;
// 
// }


import esride.opendatabridge.agolreader.IAgolItemReader;
import esride.opendatabridge.agolwriter.IAgolService;
import esride.opendatabridge.pipeline.controller.PipelineController;
import esride.opendatabridge.processinfo.IProcessInfo;
import esride.opendatabridge.reader.IReader;
import esride.opendatabridge.reader.ReaderException;
import esride.opendatabridge.reader.factory.CatalogReaderFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import java.util.HashMap;
package esride.opendatabridge.application;



/**
 * The AppInitializer manages the main components ({@link esride.opendatabridge.agolwriter.AgolService AgolService} and Catalog Adapter
 * via {@link esride.opendatabridge.reader.factory.CatalogReaderFactory CatalogReaderFactory}) via Spring configuration
 * User: sma
 * Date: 03.05.13
 * Time: 14:50
 */
public class AppInitializer {
    
    private IReader reader;

    private IAgolService agolService;

    private IAgolItemReader agolItemReader;

    private PipelineController pipelineController;


    public AppInitializer(StartParameter startParam) throws ReaderException {

        //Spring initialisieren
        ApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"appconfig/transformerConfig.xml"});

        //Auslesen der Process Informationen
        IProcessInfo processInfo = context.getBean(startParam.getReaderValue() + "ProcessInfo", IProcessInfo.class);
        HashMap<String, String> properties = processInfo.getProperties(startParam.getPidValue());

        //ReaderFactory initialisieren
        CatalogReaderFactory factory = context.getBean("readerfactory", CatalogReaderFactory.class);        
        reader = factory.newReaderInstance(startParam.getReaderValue(), properties, startParam.getPidValue());

        //AgolService auslesen
        agolService = context.getBean("agolservice", IAgolService.class);

        //PipelineController auslesen
// Path: api/agol-writer/src/main/java/esride/opendatabridge/agolreader/IAgolItemReader.java
// public interface IAgolItemReader {
// 
//     public AgolItem getAgolItemById(String agolId);
// 
//     public List<String> getAgolItemIdByTitle(String title);
// 
//     public List<String> getAgolItemIdByUrl(String url);
// 
//     public String getAgolItemIdByCatalogId(String catalogId);
// 
//     public void touchItem(String agolId);
// 
//     public List<String> getUntouchedAgolItems();
// 
// }
// 
// Path: api/agol-writer/src/main/java/esride/opendatabridge/agolwriter/IAgolService.java
// public interface IAgolService {
// 
// 
//     public void insertItem(AgolItem agolItem, AccessType accessType) throws IOException;
// 
//     public void updateItem(AgolItem agolItem, AccessType accessType, boolean overwriteAccessType) throws IOException;
// 
//     public void deleteItem(String agolId) throws IOException;
// 
//     /**
//      * Wrapper: Create ArcGIS Online Item from HashMap
//      * @param agolItemProperties
//      * @return
//      */
//     AgolItem createAgolItem(HashMap agolItemProperties) throws AgolItemInvalidException;
// 
//     /**
//      * Merge 2 ArcGIS Online Items by copying metadata from source to target and leaving
//      * @param sourceItem
//      * @param targetItem
//      * @return
//      */
//     AgolItem mergeAgolItems(AgolItem sourceItem, AgolItem targetItem);
// }
// 
// Path: api/objectpipeline/src/main/java/esride/opendatabridge/pipeline/controller/PipelineController.java
// public class PipelineController implements IPipeline{
// 
//     private ArrayList<IPipeline> pipelineList;
// 
//     public void setPipelineList(ArrayList<IPipeline> pPipelineList) {
//         pipelineList = pPipelineList;
//     }
// 
//     public void examineAndChangeObject(HashMap<String, String> elements) throws InvalidObjectException {
//         if(pipelineList != null){
//             for(int i=0; i<pipelineList.size(); i++){
//                 pipelineList.get(i).examineAndChangeObject(elements);
//             }
//         }
//     }
// }
// 
// Path: api/catalog-reader/src/main/java/esride/opendatabridge/reader/IReader.java
// public interface IReader {
// 
//     public TransformedItemResult getTramsformedItemsFromCatalog(int startPos) throws ReaderException;
// 
//     public MetadataObjectResult getItemsFromCatalog(int startPos) throws ReaderException;
// 
// }


// Path: api/transformation/src/main/java/esride/opendatabridge/application/AppInitializer.java
import esride.opendatabridge.agolreader.IAgolItemReader;
import esride.opendatabridge.agolwriter.IAgolService;
import esride.opendatabridge.pipeline.controller.PipelineController;
import esride.opendatabridge.processinfo.IProcessInfo;
import esride.opendatabridge.reader.IReader;
import esride.opendatabridge.reader.ReaderException;
import esride.opendatabridge.reader.factory.CatalogReaderFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import java.util.HashMap;

package esride.opendatabridge.application;



/**
 * The AppInitializer manages the main components ({@link esride.opendatabridge.agolwriter.AgolService AgolService} and Catalog Adapter
 * via {@link esride.opendatabridge.reader.factory.CatalogReaderFactory CatalogReaderFactory}) via Spring configuration
 * User: sma
 * Date: 03.05.13
 * Time: 14:50
 */
public class AppInitializer {
    
    private IReader reader;

    private IAgolService agolService;

    private IAgolItemReader agolItemReader;

    private PipelineController pipelineController;


    public AppInitializer(StartParameter startParam) throws ReaderException {

        //Spring initialisieren
        ApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"appconfig/transformerConfig.xml"});

        //Auslesen der Process Informationen
        IProcessInfo processInfo = context.getBean(startParam.getReaderValue() + "ProcessInfo", IProcessInfo.class);
        HashMap<String, String> properties = processInfo.getProperties(startParam.getPidValue());

        //ReaderFactory initialisieren
        CatalogReaderFactory factory = context.getBean("readerfactory", CatalogReaderFactory.class);        
        reader = factory.newReaderInstance(startParam.getReaderValue(), properties, startParam.getPidValue());

        //AgolService auslesen
        agolService = context.getBean("agolservice", IAgolService.class);

        //PipelineController auslesen
        pipelineController = context.getBean("pipelinecontroller", PipelineController.class);