Example usage for java.util Map put

List of usage examples for java.util Map put

Introduction

In this page you can find the example usage for java.util Map put.

Prototype

V put(K key, V value);

Source Link

Document

Associates the specified value with the specified key in this map (optional operation).

Usage

From source file:com.example.geomesa.kafka.KafkaQuickStart.java

public static void main(String[] args) throws Exception {
    // read command line args for a connection to Kafka
    CommandLineParser parser = new BasicParser();
    Options options = getCommonRequiredOptions();
    CommandLine cmd = parser.parse(options, args);

    // create the producer and consumer KafkaDataStore objects
    Map<String, String> dsConf = getKafkaDataStoreConf(cmd);
    dsConf.put("kafka.consumer.count", "0");
    DataStore producerDS = DataStoreFinder.getDataStore(dsConf);
    dsConf.put("kafka.consumer.count", "1");
    DataStore consumerDS = DataStoreFinder.getDataStore(dsConf);

    // verify that we got back our KafkaDataStore objects properly
    if (producerDS == null) {
        throw new Exception("Null producer KafkaDataStore");
    }//from   w  w w . ja va2 s  .  com
    if (consumerDS == null) {
        throw new Exception("Null consumer KafkaDataStore");
    }

    try {
        // create the schema which creates a topic in Kafka
        // (only needs to be done once)
        final String sftName = "KafkaQuickStart";
        final String sftSchema = "name:String,age:Int,dtg:Date,*geom:Point:srid=4326";
        SimpleFeatureType sft = SimpleFeatureTypes.createType(sftName, sftSchema);
        producerDS.createSchema(sft);

        if (!cmd.hasOption("automated")) {
            System.out.println("Register KafkaDataStore in GeoServer (Press enter to continue)");
            System.in.read();
        }

        // the live consumer must be created before the producer writes features
        // in order to read streaming data.
        // i.e. the live consumer will only read data written after its instantiation
        SimpleFeatureSource consumerFS = consumerDS.getFeatureSource(sftName);
        SimpleFeatureStore producerFS = (SimpleFeatureStore) producerDS.getFeatureSource(sftName);

        // creates and adds SimpleFeatures to the producer every 1/5th of a second
        System.out.println("Writing features to Kafka... refresh GeoServer layer preview to see changes");
        long replayStart = System.currentTimeMillis();

        String vis = cmd.getOptionValue("visibility");
        if (vis != null)
            System.out.println("Writing features with " + vis);
        addSimpleFeatures(sft, producerFS, vis);
        long replayEnd = System.currentTimeMillis();

        // read from Kafka after writing all the features.
        // LIVE CONSUMER - will obtain the current state of SimpleFeatures
        System.out.println("\nConsuming with the live consumer...");
        SimpleFeatureCollection featureCollection = consumerFS.getFeatures();
        System.out.println(featureCollection.size() + " features were written to Kafka");

        addDeleteNewFeature(sft, producerFS);

        // read from Kafka after writing all the features.
        // LIVE CONSUMER - will obtain the current state of SimpleFeatures
        System.out.println("\nConsuming with the live consumer...");
        featureCollection = consumerFS.getFeatures();
        System.out.println(featureCollection.size() + " features were written to Kafka");

        // the state of the two SimpleFeatures is real time here
        System.out.println("Here are the two SimpleFeatures that were obtained with the live consumer:");
        SimpleFeatureIterator featureIterator = featureCollection.features();
        SimpleFeature feature1 = featureIterator.next();
        SimpleFeature feature2 = featureIterator.next();
        featureIterator.close();
        printFeature(feature1);
        printFeature(feature2);

        if (System.getProperty("clear") != null) {
            // Run Java command with -Dclear=true
            // This will cause a 'clear'
            producerFS.removeFeatures(Filter.INCLUDE);
        }
    } finally {
        producerDS.dispose();
        consumerDS.dispose();
    }

    System.exit(0);
}

From source file:com.sxj.spring.modules.mapper.JsonMapper.java

public static void main(String... args) throws JsonProcessingException, IOException {
    JsonMapper mapper = JsonMapper.nonEmptyMapper();
    CJ30 cj30 = new CJ30();
    Map<String, String> name = cj30.getName();
    name.put("2", "");
    name.put("3", "?");
    name.put("4", "");
    name.put("5", "");
    name.put("7", "");
    name.put("8", "?");
    Map<String, Map<String, Data>> data = cj30.getData();
    Map<String, Data> subject1 = new HashMap<String, Data>();
    Data d1 = new Data();
    d1.setDate("01/14");
    d1.setMin(41700);/*from   ww w.  j a  v  a  2s  .  co m*/
    d1.setMax(41780);
    d1.setAverage(41740);
    subject1.put("1421164800", d1);

    Data d2 = new Data();
    d2.setDate("01/15");
    d2.setMin(41550);
    d2.setMax(41620);
    d2.setAverage(41585);
    subject1.put("1421251200", d2);
    data.put("2", subject1);

    Map<String, Data> subject2 = new HashMap<String, Data>();
    Data d3 = new Data();
    d3.setDate("01/14");
    d3.setMin(12450);
    d3.setMax(12490);
    d3.setAverage(12470);
    subject2.put("1421164800", d3);

    Data d4 = new Data();
    d4.setDate("01/15");
    d4.setMin(12730);
    d4.setMax(12770);
    d4.setAverage(12750);
    subject2.put("1421251200", d4);
    data.put("3", subject2);
    String json = mapper.toJson(cj30);
    System.out.println(json);

    FileReader reader = new FileReader(new File("E:\\cj30.js"));
    char[] buffer = new char[1024];
    int read = 0;
    StringBuilder sb = new StringBuilder();
    while ((read = reader.read(buffer)) > 0) {
        sb.append(buffer, 0, read);
    }
    CJ30 fromJson = mapper.fromJson(sb.toString(), CJ30.class);
    System.out.println(fromJson.getName());
}

From source file:com.pansky.integration.generate.Generate.java

public static void main(String[] args) throws Exception {

    // ==========  ?? ====================

    // ??????//from  www.jav  a 2s . c  o m
    // ?{packageName}/{moduleName}/{dao,entity,service,web}/{subModuleName}/{className}

    // packageName ????applicationContext.xmlsrping-mvc.xml?base-package?packagesToScan?4?
    String packageName = "com.pansky.integration.modules";

    String moduleName = "test"; // ???sys
    String subModuleName = "test1"; // ????? 
    String className = "test1"; // ??user
    String classAuthor = "renmh"; // ThinkGem
    String functionName = ""; // ??

    // ???
    //      Boolean isEnable = false;
    Boolean isEnable = true;

    // ==========  ?? ====================

    if (!isEnable) {
        logger.error("????isEnable = true");
        return;
    }

    if (StringUtils.isBlank(moduleName) || StringUtils.isBlank(moduleName) || StringUtils.isBlank(className)
            || StringUtils.isBlank(functionName)) {
        logger.error("??????????????");
        return;
    }

    // ?
    String separator = File.separator;

    // ?
    File projectPath = new DefaultResourceLoader().getResource("").getFile();
    while (!new File(projectPath.getPath() + separator + "src" + separator + "main").exists()) {
        projectPath = projectPath.getParentFile();
    }
    logger.info("Project Path: {}", projectPath);

    // ?
    String tplPath = StringUtils
            .replace(projectPath + "/src/main/java/com/pansky/integration/generate/template", "/", separator);
    logger.info("Template Path: {}", tplPath);

    // Java
    String javaPath = StringUtils.replaceEach(
            projectPath + "/src/main/java/" + StringUtils.lowerCase(packageName), new String[] { "/", "." },
            new String[] { separator, separator });
    String javaTestPath = StringUtils.replaceEach(
            projectPath + "/src/test/java/" + StringUtils.lowerCase(packageName), new String[] { "/", "." },
            new String[] { separator, separator });
    logger.info("Java Path: {}", javaPath);

    // 
    String viewPath = StringUtils.replace(projectPath + "/src/main/webapp/WEB-INF/views", "/", separator);
    logger.info("View Path: {}", viewPath);

    // ???
    Configuration cfg = new Configuration();
    cfg.setDefaultEncoding("UTF-8");
    cfg.setDirectoryForTemplateLoading(new File(tplPath));

    // ???
    Map<String, String> model = Maps.newHashMap();
    model.put("packageName", StringUtils.lowerCase(packageName));
    model.put("moduleName", StringUtils.lowerCase(moduleName));
    model.put("subModuleName",
            StringUtils.isNotBlank(subModuleName) ? "." + StringUtils.lowerCase(subModuleName) : "");
    model.put("className", StringUtils.uncapitalize(className));
    model.put("ClassName", StringUtils.capitalize(className));
    model.put("classAuthor", StringUtils.isNotBlank(classAuthor) ? classAuthor : "Generate Tools");
    model.put("classVersion", DateUtils.getDate());
    model.put("functionName", functionName);
    model.put("tableName",
            model.get("moduleName")
                    + (StringUtils.isNotBlank(subModuleName) ? "_" + StringUtils.lowerCase(subModuleName) : "")
                    + "_" + model.get("className"));
    model.put("urlPrefix",
            model.get("moduleName")
                    + (StringUtils.isNotBlank(subModuleName) ? "/" + StringUtils.lowerCase(subModuleName) : "")
                    + "/" + model.get("className"));
    model.put("viewPrefix", //StringUtils.substringAfterLast(model.get("packageName"),".")+"/"+
            model.get("urlPrefix"));
    model.put("permissionPrefix",
            model.get("moduleName")
                    + (StringUtils.isNotBlank(subModuleName) ? ":" + StringUtils.lowerCase(subModuleName) : "")
                    + ":" + model.get("className"));

    // ? Entity
    Template template = cfg.getTemplate("entity.ftl");
    String content = FreeMarkers.renderTemplate(template, model);
    String filePath = javaPath + separator + model.get("moduleName") + separator + "entity" + separator
            + StringUtils.lowerCase(subModuleName) + separator + model.get("ClassName") + ".java";
    writeFile(content, filePath);
    logger.info("Entity: {}", filePath);

    // ? Dao
    template = cfg.getTemplate("dao.ftl");
    content = FreeMarkers.renderTemplate(template, model);
    filePath = javaPath + separator + model.get("moduleName") + separator + "dao" + separator
            + StringUtils.lowerCase(subModuleName) + separator + model.get("ClassName") + "Dao.java";
    writeFile(content, filePath);
    logger.info("Dao: {}", filePath);

    // ? Service
    template = cfg.getTemplate("service.ftl");
    content = FreeMarkers.renderTemplate(template, model);
    filePath = javaPath + separator + model.get("moduleName") + separator + "service" + separator
            + StringUtils.lowerCase(subModuleName) + separator + model.get("ClassName") + "Service.java";
    writeFile(content, filePath);
    logger.info("Service: {}", filePath);

    // ? Controller
    template = cfg.getTemplate("controller.ftl");
    content = FreeMarkers.renderTemplate(template, model);
    filePath = javaPath + separator + model.get("moduleName") + separator + "web" + separator
            + StringUtils.lowerCase(subModuleName) + separator + model.get("ClassName") + "Controller.java";
    writeFile(content, filePath);
    logger.info("Controller: {}", filePath);

    // ? ViewForm
    template = cfg.getTemplate("viewForm.ftl");
    content = FreeMarkers.renderTemplate(template, model);
    filePath = viewPath + separator + StringUtils.substringAfterLast(model.get("packageName"), ".") + separator
            + model.get("moduleName") + separator + StringUtils.lowerCase(subModuleName) + separator
            + model.get("className") + "Form.jsp";
    writeFile(content, filePath);
    logger.info("ViewForm: {}", filePath);

    // ? ViewList
    template = cfg.getTemplate("viewList.ftl");
    content = FreeMarkers.renderTemplate(template, model);
    filePath = viewPath + separator + StringUtils.substringAfterLast(model.get("packageName"), ".") + separator
            + model.get("moduleName") + separator + StringUtils.lowerCase(subModuleName) + separator
            + model.get("className") + "List.jsp";
    writeFile(content, filePath);
    logger.info("ViewList: {}", filePath);
    //?TestCase
    template = cfg.getTemplate("serviceTest.ftl");
    content = FreeMarkers.renderTemplate(template, model);
    filePath = javaTestPath + separator + model.get("moduleName") + separator + "service" + separator
            + StringUtils.lowerCase(subModuleName) + separator + model.get("ClassName") + "ServiceTest.java";
    writeFile(content, filePath);
    logger.info("Service: {}", filePath);
    logger.info("Generate Success.");
}

From source file:org.ala.hbase.AdfInfoSourceUrlUpdater.java

/**
 * Usage: outputFileName [option: cassandraAddress cassandraPort]
 * //  w w  w  . ja  va 2 s  .c om
 * @param args
 */
public static void main(String[] args) throws Exception {
    Map<String, String> hashtable = new Hashtable<String, String>();
    for (int i = 0; i < args.length; i++) {
        String infoId = args[i].substring(0, args[i].indexOf(':'));
        String url = args[i].substring(args[i].indexOf(':') + 1);
        hashtable.put(infoId, url);
    }

    ApplicationContext context = SpringUtils.getContext();
    AdfInfoSourceUrlUpdater loader = context.getBean(AdfInfoSourceUrlUpdater.class);

    try {
        loader.doFullScan(hashtable);
    } catch (Exception e) {
        System.out.println("***** Fatal Error !!!.... shutdown cassandra connection.");
        e.printStackTrace();
        logger.error(e);
        System.exit(0);
    }
    System.exit(0);
}

From source file:com.glaf.core.config.SystemConfig.java

public static void main(String[] args) {
    Date now = new Date();
    Map<String, Object> sysMap = new java.util.HashMap<String, Object>();
    sysMap.put("curr_yyyymmdd", DateUtils.getYearMonthDay(now));
    sysMap.put("curr_yyyymm", DateUtils.getYearMonth(now));
    System.out.println(Mvel2ExpressionEvaluator.evaluate("${curr_yyyymmdd}-1", sysMap));
}

From source file:learn.encryption.ssl.SSLContext_Https.java

public static void main(String[] args) throws IOException, IllegalArgumentException, IllegalAccessException {
    //         getSSLContext2("D:\\https_dsmzg_2018\\dsm-server-2018.cer","D:\\SubFile\\JOB_BACKUP\\DevelopmentDocuments\\HTTPS?\\https_dsmzg_2017\\https-dsmclient.p12","clientkey@dsm2017");
    getSSLContext2("D:\\SubFile\\JOB_BACKUP\\?\\HTTPS?\\https_dsmzg_2017\\https-dsmserver.cer",
            "D:\\SubFile\\JOB_BACKUP\\?\\HTTPS?\\https_dsmzg_2017\\https-dsmclient.p12",
            "clientkey@dsm2017");
    //SSLSession session = sslContext.createSSLEngine("192.168.1.186", 443).getSession();

    // URL //from   w  w  w . j  a v  a  2  s .  co m
    String url = "https://192.168.1.186:4437/xiaodi/ads/getLockAdverList?account=18668165280";
    Map<String, String> params = new HashMap<String, String>();
    params.put("account", "18668165280");
    post(url, 10, params);
    //         String result = post(url, params);
    //         System.out.println(result);
    //      URL myURL = new URL("https://192.168.1.186:4437/xiaodi/server/reloadPartnerInfo");
    //      URL myURL = new URL("https://192.168.1.115:4437/xiaodi/ads/getLockAdverList?account=18668165280&token=A04BCQULBDgEFB1BQk5cU1NRU19cQU1WWkBPCg0FAwIkCVpZWl1UVExTXFRDSFZSSVlPSkADGhw7HAoQEQMDRFhAWUJYV0hBVE4JAxQLCQlPQ1oiNig/KSsmSEBPGBsAFxkDEkBYSF1eTk1USVldU1FQSEBPFh0OMQhPXEBQSBE=");

}

From source file:com.mycompany.sparkrentals.Main.java

public static void main(String[] args) {

    initializeSolrCqlHostsFromArgs(args);

    // Configure Solr connection
    RentalSolrClient solrClient = new RentalSolrClient();
    solrClient.connect(solrUrl);/*  ww w  .  j a  v  a2 s  .c  o  m*/

    // Configure Cassandra connection
    CqlClient cqlClient = new CqlClient();
    cqlClient.connect(cqlHost);
    cqlClient.setCqlKeyspace(cqlKeyspace);

    // Configure the view directory
    Configuration viewConfig = new Configuration();
    viewConfig.setClassForTemplateLoading(Main.class, "/views");
    FreeMarkerEngine freeMarkerEngine = new FreeMarkerEngine(viewConfig);

    // Configure the static files directory
    staticFileLocation("/public");

    //exception handling
    exception(DriverException.class, (exception, request, response) -> {
        //handle exception for cassandra serve exception
        response.body("Something wrong for cassandra server " + exception.getMessage());
    });
    exception(Exception.class, (exception, request, response) -> {
        //handle exception
        response.body("Sorry something went wrong. Please try again later.");
    });

    //start setting up routes here
    get("/add", (request, response) -> {
        Map<String, Object> attributes = new HashMap<>();

        attributes.put("data", new HashMap<>());
        fillFormSelectionOption(attributes);

        return new ModelAndView(attributes, "add.ftl");
    }, freeMarkerEngine);

    post("/add", (request, response) -> {
        Map<String, Object> attributes = new HashMap<>();

        AddRentalForm form = new AddRentalForm();
        form.setQueryMap(request.queryMap());
        if (form.validate()) {

            //valid rental data, so will insert into database and solr
            // or it'll update if one recrod already exists with the same key
            Rental rental = new Rental();
            rental.SetValuesFromMap(form.getCleanedData());
            //Assuming for now there's only one currency $
            //so we don't need to ask the user to select, we preset it here
            rental.setCurrency("$");
            rental.setUpdated(new Date());

            //insert into cql db
            cqlClient.insertOrUpdateRental(rental);

            //add index to solr at the same time
            try {
                solrClient.addRental(rental);
            } catch (IOException e) {
                attributes.put("message", "exception connecting to solr server");
                return new ModelAndView(attributes, "exception.ftl");
            } catch (SolrServerException e) {
                attributes.put("message", "solr server exception");
                return new ModelAndView(attributes, "exception.ftl");
            }

            return new ModelAndView(attributes, "add_done.ftl");

        }
        // form contains errors
        attributes.put("errorMessages", form.getErrorMessages());
        attributes.put("data", form.getDataToDisplay());
        fillFormSelectionOption(attributes);

        return new ModelAndView(attributes, "add.ftl");

    }, freeMarkerEngine);

    //index is the search page
    get("/", (request, response) -> {

        Map<String, Object> attributes = new HashMap<>();
        SearchRentalForm form = new SearchRentalForm();
        form.setQueryMap(request.queryMap());

        int perPage = 20; //number of results per page
        if (form.validate()) {
            Map<String, Object> cleanedData = form.getCleanedData();

            //get the search results from SOLR
            try {
                QueryResponse queryResponse = solrClient.searchRentals(cleanedData, perPage);
                List<Rental> rentalList = queryResponse.getBeans(Rental.class);

                //these are for pagination purpose
                long resultsTotal = queryResponse.getResults().getNumFound();
                attributes.put("resultsTotal", resultsTotal);
                int currentPage = (int) cleanedData.getOrDefault("page", 1);
                attributes.put("currentPage", currentPage);
                long maxPage = (resultsTotal % perPage > 0 ? 1 : 0) + resultsTotal / perPage;
                attributes.put("maxPage", maxPage);

                attributes.put("rentalList", rentalList);
                attributes.put("errorMessages", new ArrayList<>());

            } catch (IOException e) {
                attributes.put("errorMessages",
                        Arrays.asList("Exception when connecting to Solr!" + e.getMessage()));
            } catch (SolrException e) {
                //there is an error for querying
                attributes.put("errorMessages", Arrays.asList("Solr query error!"));
            }

        } else {
            //search form not valid
            attributes.put("rentalList", new ArrayList<>());
            attributes.put("errorMessages", form.getErrorMessages());
        }
        if (!attributes.containsKey("rentalList")) {
            attributes.put("rentalList", new ArrayList<>());
        }
        //for disply back to user entered data
        attributes.put("data", form.getDataToDisplay());

        fillFormSelectionOption(attributes);
        return new ModelAndView(attributes, "index.ftl");
    }, freeMarkerEngine);
}

From source file:io.s4.comm.util.JSONUtil.java

public static void main(String[] args) {
    Map<String, Object> outerMap = new HashMap<String, Object>();

    outerMap.put("doubleValue", 0.3456d);
    outerMap.put("integerValue", 175647);
    outerMap.put("longValue", 0x0000005000067000l);
    outerMap.put("stringValue", "Hello there");

    Map<String, Object> innerMap = null;
    List<Map<String, Object>> innerList1 = new ArrayList<Map<String, Object>>();

    innerMap = new HashMap<String, Object>();
    innerMap.put("name", "kishore");
    innerMap.put("count", 1787265);
    innerList1.add(innerMap);/*from   ww w.j  av a  2 s.co  m*/
    innerMap = new HashMap<String, Object>();
    innerMap.put("name", "fred");
    innerMap.put("count", 11);
    innerList1.add(innerMap);

    outerMap.put("innerList1", innerList1);

    List<Integer> innerList2 = new ArrayList<Integer>();
    innerList2.add(65);
    innerList2.add(2387894);
    innerList2.add(456);

    outerMap.put("innerList2", innerList2);

    JSONObject jsonObject = toJSONObject(outerMap);

    String flatJSONString = null;
    try {
        System.out.println(jsonObject.toString(3));
        flatJSONString = jsonObject.toString();
        Object o = jsonObject.get("innerList1");
        if (!(o instanceof JSONArray)) {
            System.out.println("Unexpected type of list " + o.getClass().getName());
        } else {
            JSONArray jsonArray = (JSONArray) o;
            o = jsonArray.get(0);
            if (!(o instanceof JSONObject)) {
                System.out.println("Unexpected type of map " + o.getClass().getName());
            } else {
                JSONObject innerJSONObject = (JSONObject) o;
                System.out.println(innerJSONObject.get("name"));
            }
        }
    } catch (JSONException je) {
        je.printStackTrace();
    }

    if (!flatJSONString.equals(toJsonString(outerMap))) {
        System.out.println("JSON strings don't match!!");
    }

    Map<String, Object> map = getMapFromJson(flatJSONString);

    Object o = map.get("doubleValue");
    if (!(o instanceof Double)) {
        System.out.println("Expected type Double, got " + o.getClass().getName());
        Double doubleValue = (Double) o;
        if (doubleValue != 0.3456d) {
            System.out.println("Expected 0.3456, got " + doubleValue);
        }
    }

    o = map.get("innerList1");
    if (!(o instanceof List)) {
        System.out.println("Expected implementation of List, got " + o.getClass().getName());
    } else {
        List innerList = (List) o;
        o = innerList.get(0);
        if (!(o instanceof Map)) {
            System.out.println("Expected implementation of Map, got " + o.getClass().getName());
        } else {
            innerMap = (Map) o;
            System.out.println(innerMap.get("name"));
        }
    }
    System.out.println(map);
}

From source file:org.hcmut.emr.SessionBuilder.java

public static void main(String[] args) throws FileNotFoundException, IOException {
    try (BufferedReader br = new BufferedReader(
            new FileReader("/home/sinhlk/myspace/emr/src/main/resources/patern"))) {
        ObjectMapper jsonMapper = new ObjectMapper();
        String line = br.readLine();
        Map<String, String> result = new HashMap<String, String>();
        List<NameValuePair> list = new ArrayList<>();

        while (line != null) {
            if (line != null && line != "") {
                list.add(new BasicNameValuePair(line.trim().toLowerCase(), SessionBuilder.buildValue(line)));
                result.put(line.trim().toLowerCase(), SessionBuilder.buildValue(line));
                line = br.readLine();/* w  w  w.  j a v  a  2 s .  c  om*/
            }
        }
        System.out.println(jsonMapper.writeValueAsString(list));
        File file = new File("/home/sinhlk/myspace/emr/src/main/resources/session.js");
        jsonMapper.writeValue(file, list);
    }

}

From source file:fr.inria.atlanmod.kyanos.benchmarks.KyanosGraphCreator.java

public static void main(String[] args) {
    Options options = new Options();

    Option inputOpt = OptionBuilder.create(IN);
    inputOpt.setArgName("INPUT");
    inputOpt.setDescription("Input file");
    inputOpt.setArgs(1);//  w  ww  .j  ava 2  s . co m
    inputOpt.setRequired(true);

    Option outputOpt = OptionBuilder.create(OUT);
    outputOpt.setArgName("OUTPUT");
    outputOpt.setDescription("Output directory");
    outputOpt.setArgs(1);
    outputOpt.setRequired(true);

    Option inClassOpt = OptionBuilder.create(EPACKAGE_CLASS);
    inClassOpt.setArgName("CLASS");
    inClassOpt.setDescription("FQN of EPackage implementation class");
    inClassOpt.setArgs(1);
    inClassOpt.setRequired(true);

    Option optFileOpt = OptionBuilder.create(OPTIONS_FILE);
    optFileOpt.setArgName("FILE");
    optFileOpt.setDescription("Properties file holding the options to be used in the Kyanos Resource");
    optFileOpt.setArgs(1);

    options.addOption(inputOpt);
    options.addOption(outputOpt);
    options.addOption(inClassOpt);
    options.addOption(optFileOpt);

    CommandLineParser parser = new PosixParser();

    try {

        PersistenceBackendFactoryRegistry.getFactories().put(NeoBlueprintsURI.NEO_GRAPH_SCHEME,
                new BlueprintsPersistenceBackendFactory());

        CommandLine commandLine = parser.parse(options, args);

        URI sourceUri = URI.createFileURI(commandLine.getOptionValue(IN));
        URI targetUri = NeoBlueprintsURI.createNeoGraphURI(new File(commandLine.getOptionValue(OUT)));

        Class<?> inClazz = KyanosGraphCreator.class.getClassLoader()
                .loadClass(commandLine.getOptionValue(EPACKAGE_CLASS));
        inClazz.getMethod("init").invoke(null);

        ResourceSet resourceSet = new ResourceSetImpl();

        resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xmi",
                new XMIResourceFactoryImpl());
        resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("zxmi",
                new XMIResourceFactoryImpl());
        resourceSet.getResourceFactoryRegistry().getProtocolToFactoryMap()
                .put(NeoBlueprintsURI.NEO_GRAPH_SCHEME, PersistentResourceFactory.eINSTANCE);

        Resource sourceResource = resourceSet.createResource(sourceUri);
        Map<String, Object> loadOpts = new HashMap<String, Object>();
        if ("zxmi".equals(sourceUri.fileExtension())) {
            loadOpts.put(XMIResource.OPTION_ZIP, Boolean.TRUE);
        }

        Runtime.getRuntime().gc();
        long initialUsedMemory = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
        LOG.log(Level.INFO, MessageFormat.format("Used memory before loading: {0}",
                MessageUtil.byteCountToDisplaySize(initialUsedMemory)));
        LOG.log(Level.INFO, "Loading source resource");
        sourceResource.load(loadOpts);
        LOG.log(Level.INFO, "Source resource loaded");
        Runtime.getRuntime().gc();
        long finalUsedMemory = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
        LOG.log(Level.INFO, MessageFormat.format("Used memory after loading: {0}",
                MessageUtil.byteCountToDisplaySize(finalUsedMemory)));
        LOG.log(Level.INFO, MessageFormat.format("Memory use increase: {0}",
                MessageUtil.byteCountToDisplaySize(finalUsedMemory - initialUsedMemory)));

        Resource targetResource = resourceSet.createResource(targetUri);

        Map<String, Object> saveOpts = new HashMap<String, Object>();

        if (commandLine.hasOption(OPTIONS_FILE)) {
            Properties properties = new Properties();
            properties.load(new FileInputStream(new File(commandLine.getOptionValue(OPTIONS_FILE))));
            for (final Entry<Object, Object> entry : properties.entrySet()) {
                saveOpts.put((String) entry.getKey(), (String) entry.getValue());
            }
        }
        List<StoreOption> storeOptions = new ArrayList<StoreOption>();
        storeOptions.add(BlueprintsResourceOptions.EStoreGraphOption.AUTOCOMMIT);
        saveOpts.put(BlueprintsResourceOptions.STORE_OPTIONS, storeOptions);
        targetResource.save(saveOpts);

        LOG.log(Level.INFO, "Start moving elements");
        targetResource.getContents().clear();
        targetResource.getContents().addAll(sourceResource.getContents());
        LOG.log(Level.INFO, "End moving elements");
        LOG.log(Level.INFO, "Start saving");
        targetResource.save(saveOpts);
        LOG.log(Level.INFO, "Saved");

        if (targetResource instanceof PersistentResourceImpl) {
            PersistentResourceImpl.shutdownWithoutUnload((PersistentResourceImpl) targetResource);
        } else {
            targetResource.unload();
        }

    } catch (ParseException e) {
        MessageUtil.showError(e.toString());
        MessageUtil.showError("Current arguments: " + Arrays.toString(args));
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("java -jar <this-file.jar>", options, true);
    } catch (Throwable e) {
        MessageUtil.showError(e.toString());
    }
}