r215 - in trunk/coser-business/src/main/java/fr/ifremer/coser: bean services
Author: chatellier Date: 2010-11-16 09:32:24 +0000 (Tue, 16 Nov 2010) New Revision: 215 Log: Lecture des donn?\195?\169es du control ?\195?\160 l'ouverture du projet. Lecture des commandes lors du chargement des donn?\195?\169es. Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/bean/AbstractDataContainer.java trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/bean/AbstractDataContainer.java =================================================================== --- trunk/coser-business/src/main/java/fr/ifremer/coser/bean/AbstractDataContainer.java 2010-11-16 08:43:10 UTC (rev 214) +++ trunk/coser-business/src/main/java/fr/ifremer/coser/bean/AbstractDataContainer.java 2010-11-16 09:32:24 UTC (rev 215) @@ -5,7 +5,7 @@ * $Id$ * $HeadURL$ * %% - * Copyright (C) 2010 Codelutin, Chatellier Eric + * Copyright (C) 2010 Ifremer, Codelutin, Chatellier Eric * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as @@ -79,6 +79,7 @@ deletedDataHaul = null; dataLength = null; deletedDataLength = null; + historyCommand = null; } public DataStorage getCatch() { Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java =================================================================== --- trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java 2010-11-16 08:43:10 UTC (rev 214) +++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java 2010-11-16 09:32:24 UTC (rev 215) @@ -275,7 +275,31 @@ } } - // reload selection without data + // load control (without data and commands) + File controlDirectory = new File(projectDirectory, CoserConstants.STORAGE_CONTROL_DIRECTORY); + File controlPropertiesFile = new File(controlDirectory, "control.properties"); + Control control = new Control(); + if (controlPropertiesFile.exists()) { // si on a vraiment pas sauve le control ... + InputStream inputStream = null; + try { + Properties props = new Properties(); + inputStream = new FileInputStream(controlPropertiesFile); + props.load(inputStream); + control.fromProperties(props); + + if (log.isDebugEnabled()) { + log.debug("Read control properties file : " + controlPropertiesFile); + } + } catch (IOException ex) { + throw new CoserBusinessException("Can't read control properties file", ex); + } + finally { + IOUtils.closeQuietly(inputStream); + } + } + project.setControl(control); + + // reload selection (without data and commands) Map<String, Selection> selections = new HashMap<String, Selection>(); File selectionsDirectory = new File(projectDirectory, CoserConstants.STORAGE_SELECTION_DIRECTORY); if (selectionsDirectory.isDirectory()) { @@ -286,19 +310,16 @@ selection.setName(selectionDirectory.getName()); // relecture des informations de la selection (properties) - File propertiesFile = new File(selectionDirectory, "selection.properties"); + File selectionPropertiesFile = new File(selectionDirectory, "selection.properties"); InputStream inputStream = null; try { Properties props = new Properties(); - inputStream = new FileInputStream(propertiesFile); + inputStream = new FileInputStream(selectionPropertiesFile); props.load(inputStream); selection.fromProperties(props); - - List<Command> commands = getHistoryCommandsFromProperties(props, "selection.commands"); - selection.setHistoryCommand(commands); if (log.isDebugEnabled()) { - log.debug("Read selection properties file : " + propertiesFile); + log.debug("Read selection properties file : " + selectionPropertiesFile); } } catch (IOException ex) { throw new CoserBusinessException("Can't read selection properties file", ex); @@ -311,20 +332,19 @@ } } } - project.setSelections(selections); // relecture des informations du projet (properties) - File propertiesFile = new File(projectDirectory, "project.properties"); + File projectPropertiesFile = new File(projectDirectory, "project.properties"); InputStream inputStream = null; try { Properties props = new Properties(); - inputStream = new FileInputStream(propertiesFile); + inputStream = new FileInputStream(projectPropertiesFile); props.load(inputStream); project.fromProperties(props); if (log.isDebugEnabled()) { - log.debug("Read project properties file : " + propertiesFile); + log.debug("Read project properties file : " + projectPropertiesFile); } } catch (IOException ex) { throw new CoserBusinessException("Can't read project properties file", ex); @@ -351,7 +371,7 @@ // first free memory, clear all data project.clearData(); - Control control = new Control(); + Control control = project.getControl(); // try to load validated data first File controlDirectory = new File(projectDirectory, CoserConstants.STORAGE_CONTROL_DIRECTORY); @@ -418,21 +438,20 @@ } } - // relecture des informations du control (properties) - File propertiesFile = new File(controlDirectory, "control.properties"); - if (propertiesFile.exists()) { // si on a vraiment pas sauve le control ... + // load control commands + File controlPropertiesFile = new File(controlDirectory, "control.properties"); + if (controlPropertiesFile.exists()) { // si on a vraiment pas sauve le control ... InputStream inputStream = null; try { Properties props = new Properties(); - inputStream = new FileInputStream(propertiesFile); + inputStream = new FileInputStream(controlPropertiesFile); props.load(inputStream); - control.fromProperties(props); List<Command> commands = getHistoryCommandsFromProperties(props, "control.commands"); control.setHistoryCommand(commands); if (log.isDebugEnabled()) { - log.debug("Read control properties file : " + propertiesFile); + log.debug("Read control properties file : " + controlPropertiesFile); } } catch (IOException ex) { throw new CoserBusinessException("Can't read control properties file", ex); @@ -442,11 +461,10 @@ } } else { + // FIX future NPE control.setHistoryCommand(new ArrayList<Command>()); } - - project.setControl(control); - + return project; } @@ -488,7 +506,28 @@ } } } + + // relecture des commandes de la selection (properties) + File selectionPropertiesFile = new File(selectionDirectory, "selection.properties"); + InputStream inputStream = null; + try { + Properties props = new Properties(); + inputStream = new FileInputStream(selectionPropertiesFile); + props.load(inputStream); + + List<Command> commands = getHistoryCommandsFromProperties(props, "selection.commands"); + selection.setHistoryCommand(commands); + if (log.isDebugEnabled()) { + log.debug("Read selection properties file : " + selectionPropertiesFile); + } + } catch (IOException ex) { + throw new CoserBusinessException("Can't read selection properties file", ex); + } + finally { + IOUtils.closeQuietly(inputStream); + } + return project; }
participants (1)
-
chatellierï¼ users.labs.libre-entreprise.org