Java tutorial
/** * Copyright (c) 2014, RMIT University, Australia. * All rights reserved. * * This code is under the BSD license. See 'license.txt' for details. * Project hosted at: https://bitbucket.org/eresearchrmit/seaports-pacific.git */ package edu.rmit.eres.seaports.database; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.cfg.AnnotationConfiguration; import org.hibernate.cfg.ImprovedNamingStrategy; import org.hibernate.tool.hbm2ddl.SchemaExport; import edu.rmit.eres.seaports.model.*; /** * Class used to load the categories of elements in the database * @author Guillaume Prevost */ @SuppressWarnings("deprecation") public class CategoriesLoader { /** * Main method used to load CSIRO and CMAR data only. * On an existing database, this may duplicate data. * @param args: no parameters */ public static void main(String[] args) { AnnotationConfiguration config = new AnnotationConfiguration(); config.setNamingStrategy(ImprovedNamingStrategy.INSTANCE); config.configure("hibernate.cfg.xml"); new SchemaExport(config).create(true, true); SessionFactory factory = config.buildSessionFactory(); Session session = factory.getCurrentSession(); session.beginTransaction(); LoadCategories(session); session.getTransaction().commit(); } /** * Loads the categories of elements in the database * @param session: the Hibernate Session object which takes care of persisting objects in the database */ public static void LoadCategories(Session session) { ElementCategory observedClimateCategory = new ElementCategory("Observed climate & marine", "<p class=\"justified\">Climate change is already increasing the intensity and frequency of many extreme weather events. These occur naturally, however, climate change is influencing their intensity and their return periods; and record-breaking weather is becoming more common. </p><p class=\"justified\">This tab sets the historical and current context of climate and marine observations to assist ports to understand their current climate context. It includes:<ul><li>Climate and marine data that is publicly available from the CSIRO the Australian Bureau of Meteorology and the Fiji Meteorological service.</li><li>Applications to help ports identify their current and historical vulnerability to climate impacts are included here.</li></ul></p><p class=\"justified\">You can:<ul><li>ADD DATA - add climate and marine data to your report, investigate</li><li>APPLICATIONS to help you understand port vulnerability to the current climate</li><li>ADD TEXT - add your own text boxes and analysis <li>ADD FILE - add your own information/pictures</li></ul></p><h6>CLIMATE AND MARINE DATA</h6><p class=\"justified\">Three types of data have been selected:<ul><li>National trends for temperature and rainfall; </li><li>Regional trends for sea-level rise; and</li><li>Return periods (expressed in years) for extreme weather at specific locations (where available). </li></ul></p><p class=\"justified\">Users select from two main climate data sources in this tab: <ul><li>Observed trend</li><li>Observed extreme</li></ul></p><p class=\"justified\">All data has been chosen to support the data in the Future Climate section. Please note, however, that the Future Climate is based on modelled data and is not directly comparable to the factual data sourced in this section.</p?<p class=\"justified\">For further information about climate and marine conditions in the Pacific head to the Bureau of Meteorology for:<br /><a href=\"http://www.bom.gov.au/pacific/projects/pslm/index.shtml\" target=\"_blank\">Pacific Sea Level Monitoring Project</a><br /><a href=\"http://www.bom.gov.au/climate/pacific/projects.shtml\" target=\"_blank\">Pacific Seasonal Prediction and database of historical climate information and trends </a><br /><a href=\"http://www.bom.gov.au/cosppac/comp/\" target=\"_blank\">Climate and Ocean Monitoring and Prediction (COSPAC)</a></p><h6>APPLICATIONS</h6><p>Users select from two Applications:<ul><li>Port vulnerability response to specific extreme weather events in the past. This provides a visual check of how past climate events affected the port and space for the port to enter comments about how it managed this event. You can use this aid for as many climate events as you want.</li><li>Current climate vulnerability assessment of a port to extreme weather events. This provides a downloadable matrix with a priority rating. You can use this to create a table of current port vulnerability and upload the most important priorities to the online table.</li></ul></p>", "<p class="justified">Climate change is already increasing the intensity and frequency of many extreme weather events. These occur naturally, however, climate change is influencing their intensity and their return periods; and record-breaking weather is becoming more common. </p><p class="justified">This tab sets the historical and current context of climate and marine observations to assist ports to understand their current climate context. It includes:<ul><li>Climate and marine data is publicly available from the CSIRO the Australian Bureau of Meteorology and the Fiji Meteorological service.</li><li>Applications to help ports identify their current and historical vulnerability to climate impacts are included here.</li></ul></p><p class="justified">You can:<ul><li>ADD DATA - add climate and marine data to your report, investigate</li><li>APPLICATIONS to help you understand port vulnerability to the current climate</li><li>ADD TEXT - add your own text boxes and analysis <li>ADD FILE - add your own information/pictures</li></ul></p><h6>CLIMATE AND MARINE DATA</h6><p class="justified">Three types of data have been selected:<ul><li>National trends for temperature and rainfall; </li><li>Regional trends for sea-level rise; and</li><li>Return periods (expressed in years) for extreme weather at specific locations (where available). </li></ul></p><p class="justified">Users select from two main climate data sources in this tab: <ul><li>Observed trend</li><li>Observed extreme</li></ul></p><p class="justified">All data has been chosen to support the data in the Future Climate section. Please note, however, that the Future Climate is based on modelled data and is not directly comparable to the factual data sourced in this section.</p><p class="justified">For further information about climate and marine conditions in the Pacific head to the Bureau of Meteorology for:<br /><a href="http://www.bom.gov.au/pacific/projects/pslm/index.shtml" target="_blank">Pacific Sea Level Monitoring Project</a><br /><a href="http://www.bom.gov.au/climate/pacific/projects.shtml" target="_blank">Pacific Seasonal Prediction and database of historical climate information and trends</a><br /><a href="http://www.bom.gov.au/cosppac/comp/" target="_blank">Climate and Ocean Monitoring and Prediction (COSPAC)</a></p><h6>APPLICATIONS</h6><p>Users select from two Applications:<ul><li>Port vulnerability response to specific extreme weather events in the past. This provides a visual check of how past climate events affected the port and space for the port to enter comments about how it managed this event. You can use this aid for as many climate events as you want.</li><li>Current climate vulnerability assessment of a port to extreme weather events. This provides a downloadable matrix with a priority rating. You can use this to create a table of current port vulnerability and upload the most important priorities to the online table.</li></ul></p>"); ElementCategory futureClimateCategory = new ElementCategory("Future climate & marine", "<p class=\"justified\">The future climate context faced by ports is an important factor in future planning and risk assessment processes. Direct impacts on ports, and indirect impacts on supply chains, will impact capital investment, maintenance requirements as well as knowledge, skill and training requirements for personnel. Understanding potential future climate impacts allows ports to adequately assess their future planning options, and accommodate the most appropriate adaptation choices.</p><p class=\"justified\">This tab assists ports to identify some of the future climate projections data relevant for their region. </p><p class=\"justified\">It includes:<ul><li>Projected climate and marine data publicly available from the CSIRO the Australian Bureau of Meteorology Pacific Climate Change Science Program and the Fiji Meteorological Service.</li><li>Applications to help ports identify their future risk to changing climate impacts</li></ul></p><p class=\"justified\">You can:<ul><li>ADD DATA - add future climate and marine data and investigate APPLICATIONS to help you understand port risks from climate change</li><li>ADD TEXT - add your own text boxes</li><li>ADD FILE - add your own information/pictures</li></ul></p><h6>CLIMATE AND MARINE DATA</h6><p class=\"justified\">Three types of data have been selected:<ul><li>Projected trends for temperature and rainfall from a base of 1990, using 3 emission scenarios (low, medium and high emissions) and centring on 3 time periods (2030, 2055, 2090).</li><li>Projected global trends for sea-level rise; and</li><li>Projected return periods (expressed in years) for extreme weather at specific locations (where available).</li></ul></p><p class=\"justified\">Users select from two main climate and marine data sources in this tab:<ul><li>Projected climate change</li><li>Projected extreme</li></ul></p><p class=\"justified\">For further information about projected future climate and marine conditions in the Pacific head to the <a href=\"http://www.pacificclimatechangescience.org/\" target=\"_blank\" title=\"PCCSP\">Pacific Climate Change Science Project</a> (PCCSP).<br />This project produced a series of reports that can be found here: <a href=\"http://www.pacificclimatechangescience.org/publications/reports/\" target=\"_blank\"> http://www.pacificclimatechangescience.org/publications/reports/</a><h6>AIDS TO IDENTIFYING FUTURE PORT VULNERABILITY TO CLIMATE IMPACTS</h6><p class=\"justified\">Users select:<br />Future climate risk assessment of port vulnerability to a changing climate. This provides a downloadable matrix with a priority rating that is derived from likelihood and consequence tables.</p><p class=\"justified\">Building on the knowledge gained using the current vulnerability aid, you can use this aid to create a list of possible future port climate risks and upload the most important risks to the online table.</p>", "<p class="justified">The future climate context faced by ports is an important factor in future planning and risk assessment processes. Direct impacts on ports, and indirect impacts on supply chains, will impact capital investment, maintenance requirements as well as knowledge, skill and training requirements for personnel. Understanding potential future climate impacts allows ports to adequately assess their future planning options, and accommodate the most appropriate adaptation choices.</p><p class="justified">This tab assists ports to identify some of the future climate projections data relevant for their region. </p><p class="justified">It includes:<ul><li>Projected climate and marine data publicly available from the CSIRO the Australian Bureau of Meteorology Pacific Climate Change Science Program and the Fiji Meteorological Service.</li><li>Applications to help ports identify their future risk to changing climate impacts</li></ul></p><p class="justified">You can:<ul><li>ADD DATA - add future climate and marine data and investigate APPLICATIONS to help you understand port risks from climate change</li><li>ADD TEXT - add your own text boxes</li><li>ADD FILE - add your own information/pictures</li></ul></p><h6>CLIMATE AND MARINE DATA</h6><p class="justified">Three types of data have been selected:<ul><li>Projected trends for temperature and rainfall from a base of 1990, using 3 emission scenarios (low, medium and high emissions) and centring on 3 time periods (2030, 2055, 2090).</li><li>Projected global trends for sea-level rise; and</li><li>Projected return periods (expressed in years) for extreme weather at specific locations (where available).</li></ul></p><p class="justified">Users select from two main climate and marine data sources in this tab:<ul><li>Projected climate change</li><li>Projected extreme</li></ul></p><p class="justified">For further information about projected future climate and marine conditions in the Pacific head to the <a href="http://www.pacificclimatechangescience.org/" target="_blank" title="PCCSP">Pacific Climate Change Science Project</a> (PCCSP).<br />This project produced a series of reports that can be found here: <a href="http://www.pacificclimatechangescience.org/publications/reports/" target="_blank"> http://www.pacificclimatechangescience.org/publications/reports/</a><h6>AIDS TO IDENTIFYING FUTURE PORT VULNERABILITY TO CLIMATE IMPACTS</h6><p class="justified">Users select:<br />Future climate risk assessment of port vulnerability to a changing climate. This provides a downloadable matrix with a priority rating that is derived from likelihood and consequence tables.</p><p class="justified">Building on the knowledge gained using the current vulnerability aid, you can use this aid to create a list of possible future port climate risks and upload the most important risks to the online table.</p>"); ElementCategory nonClimateCategory = new ElementCategory("Non-climate context", "<p class=\"justified\">Non-climate data helps set the operational context of ports. It also provides a starting point for consideration of possible impacts of non-climate factors into the future. For example, population growth along the coast can constrain a port's ability to expand in the future, and to retreat as sea level rise and climatic conditions change. National population growth can also be a driver of increased activity at container import ports, which may lead to congestion problems. </p><p class=\"justified\">This tab includes trade and population data. Note that only limited data may be available for some ports. </p><p class=\"justified\">Two publicly available data sets are offered within this section. These are urban pressure data derived from the World Bank and trade data from Fiji Statistics. </p><p class=\"justified\">Ports are encouraged to upload port-specific files and information regarding organisational objectives, current risks, or data on throughput volume or the types of activity that characterise the port. </p><p class=\"justified\">You can:<br />ADD DATA -add non-climate demographic and trade data<br />ADD TEXT - add your own text boxes<br />ADD FILE - add your own information/pictures</p><p class=\"justified\">Users can select from two data sources on this tab:<ul><li><b>Demographics</b>, which provides population change data;</li><li><b>Trade Data</b> which provides country-side import and export data</li></ul></p>", "<p class="justified">Non-climate data helps set the operational context of ports. It also provides a starting point for consideration of possible impacts of non-climate factors into the future. For example, population growth along the coast can constrain a port's ability to expand in the future, and to retreat as sea level rise and climatic conditions change. National population growth can also be a driver of increased activity at container import ports, which may lead to congestion problems. </p><p class="justified">This tab includes trade and population data. Note that only limited data may be available for some ports. </p><p class="justified">Two publicly available data sets are offered within this section. These are urban pressure data derived from the World Bank and trade data from Fiji Statistics. </p><p class="justified">Ports are encouraged to upload port-specific files and information regarding organisational objectives, current risks, or data on throughput volume or the types of activity that characterise the port. </p><p class="justified">You can:<br />ADD DATA -add non-climate demographic and trade data<br />ADD TEXT - add your own text boxes<br />ADD FILE - add your own information/pictures</p><p class="justified">Users can select from two data sources on this tab:<ul><li><b>Demographics</b>, which provides population change data;</li><li><b>Trade Data</b> which provides country-side import and export data</li></ul></p>"); ElementCategory applicationsCategory = new ElementCategory("Applications", "<p class=\"justified\">A port can vulnerable to many climate impacts including: storm, floods, cyclones, rain, heatwaves etc. In the future these impacts may increase or decrease under climate change and there may be as yet unrecognised climate impacts that will appear. The port knows best what weather current affects its operations. These Applications help the port gather the information only they have.</p><p class=\"justified\">Applications (in the form of questionnaires and tables) can be accessed and downloaded to support:<ol><li>Identify port responses to extreme weather events in the past<br />How a port has coped with, and responded to past extreme weather events, can be an indication of how well it will cope with a future climate change. This APPLICATION appears as a spider graph showing which area of port business was most affected by a past weather event</li><li>Collate perceptions of port vulnerability to the current climate<br />Climate affects different part of the port business, bringing all the climate impacts into one table and ranking them according to their severity will help the port understand the full extent of its current vulnerability to the climate. This APPLICATION consists of a downloadable table correlating climate impacts and areas of port business.</li><li>Providing a priority rating for the risk of future climate impacts to the port<br />Future climate risks to the port may be existing climate risks or completely new one. This APPLICATION consists of (i) a downloadable table to record the climate change description, the risk. and a current threshold that could be exceeded in the future. It has a priority rating attached that includes a consequence table and a likelihood table.</li></ol></p><p class=\"justified\">When considering the questions in this tab, think of the impact on port assets and operations (machinery, buildings, equipment), infrastructure (drainage, rail, road, berths), trade (goods moving in and out of a port) and people (injuries, work disruptions).</p>", "<p class="justified">A port can vulnerable to many climate impacts including: storm, floods, cyclones, rain, heatwaves etc. In the future these impacts may increase or decrease under climate change and there may be as yet unrecognised climate impacts that will appear. The port knows best what weather current affects its operations. These Applications help the port gather the information only they have.</p><p class="justified">Applications (in the form of questionnaires and tables) can be accessed and downloaded to support:<ol><li>Identify port responses to extreme weather events in the past<br />How a port has coped with, and responded to past extreme weather events, can be an indication of how well it will cope with a future climate change. This APPLICATION appears as a spider graph showing which area of port business was most affected by a past weather event</li><li>Collate perceptions of port vulnerability to the current climate<br />Climate affects different part of the port business, bringing all the climate impacts into one table and ranking them according to their severity will help the port understand the full extent of its current vulnerability to the climate. This APPLICATION consists of a downloadable table correlating climate impacts and areas of port business.</li><li>Providing a priority rating for the risk of future climate impacts to the port<br />Future climate risks to the port may be existing climate risks or completely new one. This APPLICATION consists of (i) a downloadable table to record the climate change description, the risk. and a current threshold that could be exceeded in the future. It has a priority rating attached that includes a consequence table and a likelihood table.</li></ol></p><p class="justified">When considering the questions in this tab, think of the impact on port assets and operations (machinery, buildings, equipment), infrastructure (drainage, rail, road, berths), trade (goods moving in and out of a port) and people (injuries, work disruptions).</p>"); session.save(observedClimateCategory); session.save(futureClimateCategory); session.save(nonClimateCategory); session.save(applicationsCategory); System.out.println("Set up element categories"); } }