From: rkv Date: Wed, 7 Nov 2012 14:32:44 +0000 (+0000) Subject: Modifications to respect PMD rules. X-Git-Tag: Root_Delivery1_2012_12_06~89 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b991fc2827c2dba4ed132453d537c6cfaa504417;p=tools%2Fsiman.git Modifications to respect PMD rules. --- diff --git a/Workspace/Siman/src/org/splat/launcher/FileTransfer.java b/Workspace/Siman/src/org/splat/launcher/FileTransfer.java index c653bfb..19420ed 100644 --- a/Workspace/Siman/src/org/splat/launcher/FileTransfer.java +++ b/Workspace/Siman/src/org/splat/launcher/FileTransfer.java @@ -8,46 +8,43 @@ import java.io.OutputStream; import java.net.URL; import java.net.URLConnection; - public class FileTransfer { - final static int size = 1024; + private final static int SIZE = 1024; - public static void Download (String path, String filename, String destination) { -// ------------------------------------------------------------------------------ - URLConnection conx = null; // Communication link between the application and a URL. - InputStream is = null; - OutputStream os = null; - try { - URL url; - byte[] buf; - int ByteRead = 0; -// int ByteWritten = 0; + public static void download(final String path, final String filename, + final String destination) { + URLConnection conx = null; // Communication link between the application and a URL. + InputStream is = null; + OutputStream os = null; + try { + URL url; + byte[] buf; + // int ByteWritten = 0; - url = new URL(path); - os = new BufferedOutputStream( new FileOutputStream(destination + "/" + filename) ); -// The URLConnection object is created by invoking the openConnection method on a URL. + url = new URL(path); + os = new BufferedOutputStream(new FileOutputStream(destination + + "/" + filename)); + // The URLConnection object is created by invoking the openConnection method on a URL. - conx = url.openConnection(); - is = conx.getInputStream(); - buf = new byte[size]; - while ((ByteRead = is.read(buf)) != -1) { - os.write(buf, 0, ByteRead); -// ByteWritten += ByteRead; - } -// System.out.println("File \"" + filename + "\" successfully downloaded"); - } - catch (Exception e) { - e.printStackTrace(); - } - finally { - try { - is.close(); - os.close(); - } - catch (IOException e) { - e.printStackTrace(); - } - } - } + conx = url.openConnection(); + is = conx.getInputStream(); + buf = new byte[SIZE]; + int ByteRead = is.read(buf); + while (ByteRead != -1) { + os.write(buf, 0, ByteRead); + ByteRead = is.read(buf); + } + // System.out.println("File \"" + filename + "\" successfully downloaded"); + } catch (Exception e) { + e.printStackTrace(); // RKV: NOPMD: TODO: try to use logger + } finally { + try { + is.close(); + os.close(); + } catch (IOException e) { + e.printStackTrace(); // RKV: NOPMD: TODO: try to use logger + } + } + } } \ No newline at end of file diff --git a/Workspace/Siman/src/org/splat/launcher/ToolButton.java b/Workspace/Siman/src/org/splat/launcher/ToolButton.java index e464386..5218a4c 100644 --- a/Workspace/Siman/src/org/splat/launcher/ToolButton.java +++ b/Workspace/Siman/src/org/splat/launcher/ToolButton.java @@ -6,61 +6,65 @@ import java.awt.Cursor; import java.awt.Graphics; import java.awt.Image; - public class ToolButton extends Button { - private Image icon; - private int orx; // X of the icon top left corner - private int ory; // Y of the icon top left corner - private String link; - private String target; + private transient final Image _icon; + private transient int _orx; // X of the icon top left corner + private transient int _ory; // Y of the icon top left corner + private transient final String _link; + private transient final String _target; private static final long serialVersionUID = 5723786125423445749L; - -// ============================================================================================================================== -// Constructors -// ============================================================================================================================== - public ToolButton (int size, Image icon, String link) { -// ----------------------------------------------------- + // ============================================================================================================================== + // Constructors + // ============================================================================================================================== + + public ToolButton(final int size, final Image icon, final String link) { this(size, icon, link, null); } - public ToolButton (int size, Image icon, String link, String target) { -// -------------------------------------------------------------------- - orx = 24; // icon.getWidth(this); seems returning 0 before being painted - ory = 24; // icon.getHeight(this); seems returning 0 before being painted - if (orx < size) orx = (size - orx) / 2; - else orx = 0; - if (ory < size) ory = (size - ory) / 2; - else ory = 0; - - this.icon = icon; - this.link = link; - this.target = target; - this.setSize(size, size); - this.setCursor(new Cursor(Cursor.HAND_CURSOR)); + + public ToolButton(final int size, final Image icon, final String link, + final String target) { + super(); + _orx = 24; // icon.getWidth(this); seems returning 0 before being painted + _ory = 24; // icon.getHeight(this); seems returning 0 before being painted + if (_orx < size) { + _orx = (size - _orx) / 2; + } else { + _orx = 0; + } + if (_ory < size) { + _ory = (size - _ory) / 2; + } else { + _ory = 0; + } + + this._icon = icon; + this._link = link; + this._target = target; + this.setSize(size, size); + this.setCursor(new Cursor(Cursor.HAND_CURSOR)); } - -// ============================================================================================================================== -// Overridden functions -// ============================================================================================================================== - public void paint(Graphics screen) { -// ---------------------------------- - screen.drawImage(icon, orx, ory, new Color(205, 229, 255), this); - } - -// ============================================================================================================================== -// Member functions -// ============================================================================================================================== + // ============================================================================================================================== + // Overridden functions + // ============================================================================================================================== - public String getTool () { -// ------------------------ - return link; - } + @Override + public void paint(final Graphics screen) { + screen.drawImage(_icon, _orx, _ory, new Color(205, 229, 255), this); + } - public String getTarget () { -// -------------------------- - return target; - } + // ============================================================================================================================== + // Member functions + // ============================================================================================================================== + + public String getTool() { + return _link; + } + + public String getTarget() { + return _target; + } } \ No newline at end of file diff --git a/Workspace/Siman/src/org/splat/launcher/ToolbarApplet.java b/Workspace/Siman/src/org/splat/launcher/ToolbarApplet.java index 063de39..c5bc176 100644 --- a/Workspace/Siman/src/org/splat/launcher/ToolbarApplet.java +++ b/Workspace/Siman/src/org/splat/launcher/ToolbarApplet.java @@ -1,119 +1,129 @@ package org.splat.launcher; +import java.awt.ComponentOrientation; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.awt.ComponentOrientation; import java.io.ObjectInputStream; import java.net.URL; import java.net.URLConnection; +public class ToolbarApplet extends java.applet.Applet implements ActionListener { + + private static final long serialVersionUID = 3243053622061086715L; -public class ToolbarApplet extends java.applet.Applet implements ActionListener { + // ============================================================================================================================== + // Overridden functions + // ============================================================================================================================== - private int width; - private int height; + @Override + public void init() { + URL appurl = getCodeBase(); + int hgap = 6; // Gap between icons + int ntools; - private static final long serialVersionUID = 3243053622061086715L; - -// ============================================================================================================================== -// Overridden functions -// ============================================================================================================================== + int width = getSize().width; + int height = getSize().height; + for (ntools = 0; ntools < (width + hgap) / (height + hgap); ntools++) { + String icon = this.getParameter("icon" + ntools); + String tool = this.getParameter("tool" + ntools); + String file = this.getParameter("file" + ntools); // May be null + if (icon != null && tool != null) { + ToolButton button = new ToolButton(height, getImage(appurl, + "../skin/" + icon), tool, file); + add(button); // For displaying the button + button.addActionListener(this); + } + } + setLayout(new GridLayout(1, ntools, hgap, 0)); // 1 row, {ntools} buttons + applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); + } - public void init () { -// ------------------- - URL appurl = getCodeBase(); - int hgap = 6; // Gap between icons - int ntools; - - width = getSize().width; - height = getSize().height; - for (ntools = 0; ntools < (width+hgap)/(height+hgap); ntools++) { - String icon = this.getParameter("icon"+ntools); - String tool = this.getParameter("tool"+ntools); - String file = this.getParameter("file"+ntools); // May be null - if (icon != null && tool != null) { - ToolButton button = new ToolButton(height, getImage(appurl, "../skin/" + icon), tool, file); - add(button); // For displaying the button - button.addActionListener(this); - } - } - setLayout( new GridLayout(1, ntools, hgap, 0) ); // 1 row, {ntools} buttons - applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); - } + public void actionPerformed(final ActionEvent event) { + // ----------------------------------------------- + if (event.getSource() instanceof ToolButton) { + ToolButton clicked = (ToolButton) event.getSource(); + String module = clicked.getTool(); + String target = clicked.getTarget(); + launch(module, target); + } + } - public void actionPerformed (ActionEvent event) { -// ----------------------------------------------- - if (event.getSource() instanceof ToolButton) { - ToolButton clicked = (ToolButton)event.getSource(); - String module = clicked.getTool(); - String target = clicked.getTarget(); - launch(module, target); - } - } - -// ============================================================================================================================== -// Public member functions -// ============================================================================================================================== + // ============================================================================================================================== + // Public member functions + // ============================================================================================================================== - public void launch (String name, String filename) { -// ------------------------------------------------- - String module = name; - try { + public void launch(final String name, final String filename) { + // ------------------------------------------------- + String module = name; + try { -// Opening a Web page in a new tab - if (module.startsWith("http")) { - getAppletContext().showDocument(new URL(module), "_blank"); - } else + // Opening a Web page in a new tab + if (module.startsWith("http")) { + getAppletContext().showDocument(new URL(module), "_blank"); + } else -// Opening a Web module in a new tab - if (module.startsWith("../") || module.startsWith("/")) { - module = getCodeBase().toString() + module; - if (filename != null) module = module + "?open=" + filename; - getAppletContext().showDocument(new URL(module), "_blank"); - } else + // Opening a Web module in a new tab + if (module.startsWith("../") || module.startsWith("/")) { + module = getCodeBase().toString() + module; + if (filename != null) { + module = module + "?open=" + filename; + } + getAppletContext().showDocument(new URL(module), "_blank"); + } else -// Opening an application on the local machine - if (module.endsWith(".exe") || module.endsWith(".EXE")) { - String applikey = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Classes\\Applications\\" + module; - String valkey = ""; // Default application and file keys + // Opening an application on the local machine + if (module.endsWith(".exe") || module.endsWith(".EXE")) { + String applikey = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Classes\\Applications\\" + + module; + String valkey = ""; // Default application and file keys - module = WindowsRegistry.readValue(applikey + "\\shell\\open\\command", valkey); - if (module == null) module = WindowsRegistry.readValue(applikey + "\\shell\\edit\\command", valkey); -// if (module == null) module = "\"C:\\Program Files (x86)\\Microsoft Office\\Office14\\WINWORD.EXE\""; - if (module != null) { - String[] parse = module.split("/"); - String command = parse[0]; // Removing eventual options - if (filename != null) { - String path = ""; -// Opening the application with a server side existing file - if (filename.startsWith("http")) { - path = " \"" + filename + "\""; - } -// Opening the application with a file previously created by the server - else if (filename.startsWith("/jsp")) { // Document created through a JSP - URL my = getDocumentBase(); - String http = "http://" + my.getHost() + ":" + my.getPort() + "/"; - String[] jsppath = my.getPath().split("/"); // Parses "/webapp/..." - String location = http + jsppath[1] + filename; + module = WindowsRegistry.readValue(applikey + + "\\shell\\open\\command", valkey); + if (module == null) { + module = WindowsRegistry.readValue(applikey + + "\\shell\\edit\\command", valkey); + } + // if (module == null) module = "\"C:\\Program Files (x86)\\Microsoft Office\\Office14\\WINWORD.EXE\""; + if (module == null) { + module = getCodeBase().toString() + + "error.jsp?message=launch&value=" + name; + getAppletContext().showDocument(new URL(module)); + } else { + String[] parse = module.split("/"); + String command = parse[0]; // Removing eventual options + if (filename != null) { + String path = ""; + // Opening the application with a server side existing file + if (filename.startsWith("http")) { + path = " \"" + filename + "\""; + } + // Opening the application with a file previously created by the server + else if (filename.startsWith("/jsp")) { // Document created through a JSP + URL my = getDocumentBase(); + String http = "http://" + my.getHost() + ":" + + my.getPort() + "/"; + String[] jsppath = my.getPath().split("/"); // Parses "/webapp/..." + String location = http + jsppath[1] + filename; - URLConnection connection = new URL(location).openConnection(); - ObjectInputStream fromservlet = new ObjectInputStream(connection.getInputStream()); - URL docurl = (URL)fromservlet.readObject(); + URLConnection connection = new URL(location) + .openConnection(); + ObjectInputStream fromservlet = new ObjectInputStream( + connection.getInputStream()); + URL docurl = (URL) fromservlet.readObject(); - fromservlet.close(); - if (docurl != null) path = " " + docurl.toString(); - } - command = command + path; - } - Runtime.getRuntime().exec(command); - } else { - module = getCodeBase().toString() + "error.jsp?message=launch&value=" + name; - getAppletContext().showDocument(new URL(module)); - } - } - } catch (Exception error) { - error.printStackTrace(); - } - } + fromservlet.close(); + if (docurl != null) { + path = " " + docurl.toString(); + } + } + command = command + path; + } + Runtime.getRuntime().exec(command); + } + } + } catch (Exception error) { + error.printStackTrace(); // RKV: NOPMD: TODO: try to use logger + } + } } \ No newline at end of file diff --git a/Workspace/Siman/src/org/splat/launcher/WindowsRegistry.java b/Workspace/Siman/src/org/splat/launcher/WindowsRegistry.java index c9c9e15..29e4f20 100644 --- a/Workspace/Siman/src/org/splat/launcher/WindowsRegistry.java +++ b/Workspace/Siman/src/org/splat/launcher/WindowsRegistry.java @@ -6,69 +6,82 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.StringWriter; - public class WindowsRegistry { - static class StreamReader extends Thread { -// ---------------------------------------- - private InputStream is; - private StringWriter sw= new StringWriter();; + private static final String REG_SZ = "REG_SZ"; + + static class StreamReader extends Thread { //RKV: NOPMD: TODO: Clarify the purpose of this class and then fix + private transient final InputStream _is; + private transient final StringWriter _sw = new StringWriter();; + + public StreamReader(final InputStream is) { + super(); + this._is = is; + } + + @Override + public void run() { + try { + int c = _is.read(); + while (c != -1) { + _sw.write(c); + c = _is.read(); + } + } catch (IOException e) { + e.printStackTrace(); // RKV: NOPMD: TODO: try to use logger + } + } + + public String getResult() { + return _sw.toString(); + } + } + + public static final String readValue(final String location, final String key) { + String res = null; + try { + // Run reg query, then read output with StreamReader (internal class) + String aKey; + if (key.length() == 0) { + aKey = "/ve"; // Looking for the default key + } else { + aKey = "/v " + key; + } - public StreamReader(InputStream is) { - this.is = is; - } - public void run() { - try { - int c; - while ((c = is.read()) != -1) sw.write(c); - } - catch (IOException e) { - } - } - public String getResult() { - return sw.toString(); - } - } + Process process = Runtime.getRuntime().exec( + "reg query " + location + " " + aKey); + BufferedReader buffer = new BufferedReader(new InputStreamReader( + process.getInputStream())); - public static final String readValue (String location, String key) { -// ------------------------------------------------------------------ - try { -// Run reg query, then read output with StreamReader (internal class) - if (key.length() == 0) key = "/ve"; // Looking for the default key - else key = "/v " + key; - - Process process = Runtime.getRuntime().exec("reg query " + location + " " + key); - BufferedReader buffer = new BufferedReader( new InputStreamReader(process.getInputStream()) ); - -// Output has the following format: -// \n\n\n\t\t - String output = null; - String value = "REG_SZ"; - while ((output = buffer.readLine()) != null) { - if (output.contains(value)) { - int index = output.indexOf(value) + value.length() + 1; - return output.substring(index).trim(); - } - } - return null; -// StreamReader reader = new StreamReader(process.getInputStream()); + // Output has the following format: + // \n\n\n\t\t + String output = buffer.readLine(); + while (output != null) { + if (output.contains(REG_SZ)) { + int index = output.indexOf(REG_SZ) + REG_SZ.length() + 1; + res = output.substring(index).trim(); + break; + } + output = buffer.readLine(); + } + // StreamReader reader = new StreamReader(process.getInputStream()); -// reader.start(); -// process.waitFor(); -// reader.join(); -// String output = reader.getResult(); + // reader.start(); + // process.waitFor(); + // reader.join(); + // String output = reader.getResult(); -// Output has the following format: -// \n\n\n\t\t -// if( ! output.contains("\t") ){ -// return null; -// } -// Parse out the value -// String[] parsed = output.split("\t"); -// return parsed[parsed.length-1]; - } - catch (Exception e) { - return null; - } - } + // Output has the following format: + // \n\n\n\t\t + // if( ! output.contains("\t") ){ + // return null; + // } + // Parse out the value + // String[] parsed = output.split("\t"); + // return parsed[parsed.length-1]; + } catch (Exception e) { + e.printStackTrace(); // RKV: NOPMD: TODO: try to use logger + } + return res; + } } \ No newline at end of file diff --git a/Workspace/Siman/src/org/splat/simer/admin/SimulationContextAction.java b/Workspace/Siman/src/org/splat/simer/admin/SimulationContextAction.java index fb79147..05d56fb 100644 --- a/Workspace/Siman/src/org/splat/simer/admin/SimulationContextAction.java +++ b/Workspace/Siman/src/org/splat/simer/admin/SimulationContextAction.java @@ -9,25 +9,23 @@ import java.util.List; import java.util.Locale; import java.util.ResourceBundle; import java.util.Set; -import java.util.Vector; import org.hibernate.Session; import org.hibernate.Transaction; - -import org.splat.simer.Action; -import org.splat.simer.ApplicationSettings; -import org.splat.dal.dao.som.Database; import org.splat.dal.bo.som.KnowledgeElement; import org.splat.dal.bo.som.ProgressState; +import org.splat.dal.bo.som.SimulationContext; +import org.splat.dal.bo.som.SimulationContextType; +import org.splat.dal.bo.som.Study; +import org.splat.dal.dao.som.Database; import org.splat.service.KnowledgeElementService; import org.splat.service.SearchService; import org.splat.service.SimulationContextService; -import org.splat.service.technical.ProjectSettingsService; import org.splat.service.dto.Proxy; import org.splat.service.dto.SimulationContextFacade; -import org.splat.dal.bo.som.SimulationContext; -import org.splat.dal.bo.som.SimulationContextType; -import org.splat.dal.bo.som.Study; +import org.splat.service.technical.ProjectSettingsService; +import org.splat.simer.Action; +import org.splat.simer.ApplicationSettings; /** * Action for operations on simulation contexts. @@ -39,14 +37,38 @@ public class SimulationContextAction extends Action { */ private static final long serialVersionUID = 7083323229359094699L; - private List tocheck; // Simulation contexts to be approved - private int selection; // Index of the selected simulation context presented in the approval form - private SimulationContext edition; // Corresponding simulation context object - private ProjectSettingsService.Step step; // Study step to which the selected simulation context is attached - private Set owner; // Study scenarios indexed by this simulation context - private List existype; // Existing approved simulation context types ordered by localized names - private List exisname; // Existing approved simulation context types ordered by internal codes - private List existing; // Existing simulation contexts of selected type + /** + * Simulation contexts to be approved. + */ + private transient List _tocheck; + /** + * Index of the selected simulation context presented in the approval form. + */ + private int _selection; + /** + * Corresponding simulation context object. + */ + private transient SimulationContext _edition; + /** + * Study step to which the selected simulation context is attached. + */ + private transient ProjectSettingsService.Step _step; + /** + * Study scenarios indexed by this simulation context. + */ + private transient Set _owner; + /** + * Existing approved simulation context types ordered by localized names. + */ + private transient List _existype; + /** + * Existing approved simulation context types ordered by internal codes. + */ + private transient List _exisname; + /** + * Existing simulation contexts of selected type. + */ + private transient List _existing; /** * Injected search service. */ @@ -54,7 +76,7 @@ public class SimulationContextAction extends Action { /** * Injected project settings service. */ - private ProjectSettingsService _projectSettingsService; + private ProjectSettingsService _projectSettings; /** * Injected knowledge element service. */ @@ -63,22 +85,19 @@ public class SimulationContextAction extends Action { * Injected simulation context service. */ private SimulationContextService _simulationContextService; - + /** - * Value of the menu property. - * It can be: none, create, open, study, knowledge, sysadmin, help. + * Value of the menu property. It can be: none, create, open, study, knowledge, sysadmin, help. */ private String _menuProperty; - + /** - * Value of the tool bar property. - * It can be: none, standard, study, back. + * Value of the tool bar property. It can be: none, standard, study, back. */ private String _toolProperty; - + /** - * Value of the left menu property. - * It can be: open, study, knowledge, scenario. + * Value of the left menu property. It can be: open, study, knowledge, scenario. */ private String _leftMenuProperty; @@ -92,7 +111,8 @@ public class SimulationContextAction extends Action { * * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) */ - public int compare(SimulationContextType t1, SimulationContextType t2) { + public int compare(final SimulationContextType t1, + final SimulationContextType t2) { String name1 = t1.getName(); String name2 = t2.getName(); @@ -101,35 +121,35 @@ public class SimulationContextAction extends Action { } public class LocalizedContextTypes { - // ---------------------------------- - private Locale locale; - private List sortype; // Existing approved simulation context types ordered by localized names + private transient final Locale _locale; + private transient final List _sortype; // Existing approved simulation context types ordered by localized names - public LocalizedContextTypes(List types, - Locale lang) { + public LocalizedContextTypes(final List types, + final Locale lang) { ResourceBundle bundle = ResourceBundle.getBundle("som", lang); SimulationContextType[] tosort = types .toArray(new SimulationContextType[types.size()]); String[] name = new String[types.size()]; - for (int i = 0; i < name.length; i++) + for (int i = 0; i < name.length; i++) { name[i] = bundle.getString("type.context." + tosort[i].getName()); + } Arrays.sort(name); - sortype = Arrays.asList(name); - locale = lang; + _sortype = Arrays.asList(name); + _locale = lang; } public String getLocale() { - return locale.toString(); + return _locale.toString(); } public List getTypeNames() { - return sortype; + return _sortype; } public boolean isCurrent() { - return (locale.equals(ApplicationSettings.getCurrentLocale())); + return _locale.equals(ApplicationSettings.getCurrentLocale()); } } @@ -139,36 +159,39 @@ public class SimulationContextAction extends Action { /** * Initialize the simulation context list. + * * @return SUCCESS if succeeded, otherwise - ERROR */ public String doInitialize() { + String res = SUCCESS; try { - tocheck = getSimulationContextService() + _tocheck = getSimulationContextService() .getSimulationContextsInState(ProgressState.inCHECK); - selection = 0; - edition = null; - owner = null; - + _selection = 0; + _edition = null; + _owner = null; + setMenuProperty("study"); setToolProperty("none"); setLeftMenuProperty("open"); - initializationFullScreenContext(_menuProperty, _toolProperty, _leftMenuProperty); - - return SUCCESS; + initializationFullScreenContext(_menuProperty, _toolProperty, + _leftMenuProperty); } catch (Exception error) { LOG.error("Reason:", error); - return ERROR; // No need to roll-back the transaction as it is read-only + res = ERROR; // No need to roll-back the transaction as it is read-only } + return res; } public String doSelect() { - // ------------------------- - + + String res = SUCCESS; setMenuProperty("study"); setToolProperty("none"); setLeftMenuProperty("open"); - initializationFullScreenContext(_menuProperty, _toolProperty, _leftMenuProperty); - + initializationFullScreenContext(_menuProperty, _toolProperty, + _leftMenuProperty); + Session connex = Database.getCurSession(); Transaction transax = connex.beginTransaction(); try { @@ -179,15 +202,15 @@ public class SimulationContextAction extends Action { List selected = new ArrayList( 1); - tocheck = new Vector(context.size()); + _tocheck = new ArrayList(context.size()); for (Iterator i = context.iterator(); i .hasNext();) { SimulationContext next = i.next(); - if (next.getIndex() == selection) { - edition = next; - selected.add(edition); + if (next.getIndex() == _selection) { + _edition = next; + selected.add(_edition); } - tocheck.add(new SimulationContextFacade(next, + _tocheck.add(new SimulationContextFacade(next, getProjectSettings().getAllSteps())); } KnowledgeElement.Properties kprop = new KnowledgeElement.Properties(); @@ -195,20 +218,21 @@ public class SimulationContextAction extends Action { kprop.setSimulationContexts(selected).setState( ProgressState.inWORK)); - step = getSimulationContextService().getAttachedStep( - edition.getType()); - owner = new HashSet(); + _step = getSimulationContextService().getAttachedStep( + _edition.getType()); + _owner = new HashSet(); for (Iterator i = kelm.iterator(); i.hasNext();) { KnowledgeElement next = getKnowledgeElementService() .selectKnowledgeElement(i.next().getIndex()); ProjectElementFacade facade; - if (step.appliesTo(Study.class)) + if (_step.appliesTo(Study.class)) { facade = new ProjectElementFacade(next.getOwnerScenario() - .getOwnerStudy(), step); - else + .getOwnerStudy(), _step); + } else { facade = new ProjectElementFacade(next.getOwnerScenario(), - step); - owner.add(facade); + _step); + } + _owner.add(facade); } SimulationContextType.Properties sprop = new SimulationContextType.Properties(); List types = getSimulationContextService() @@ -217,27 +241,27 @@ public class SimulationContextAction extends Action { Locale[] support = ApplicationSettings.getSupportedLocales(); // Sort localized type names - existype = new ArrayList(support.length); + _existype = new ArrayList(support.length); for (int i = 0; i < support.length; i++) { - existype.add(new LocalizedContextTypes(types, support[i])); + _existype.add(new LocalizedContextTypes(types, support[i])); } SimulationContextType[] names = types .toArray(new SimulationContextType[types.size()]); Arrays.sort(names, new ContextNameComparator()); - exisname = Arrays.asList(names); + _exisname = Arrays.asList(names); - existing = getSimulationContextService() + _existing = getSimulationContextService() .selectSimulationContextsWhere( - cprop.setType(edition.getType()).setState( + cprop.setType(_edition.getType()).setState( ProgressState.APPROVED)); transax.commit(); - return SUCCESS; } catch (Exception error) { LOG.error("Reason:", error); - return ERROR; // No need to roll-back the transaction as it is read-only + res = ERROR; // No need to roll-back the transaction as it is read-only } + return res; } // ============================================================================================================================== @@ -245,7 +269,6 @@ public class SimulationContextAction extends Action { // ============================================================================================================================== public List getAllStudySteps() { - // ----------------------------------------------------- return getProjectSettings().getAllSteps(); } @@ -255,7 +278,7 @@ public class SimulationContextAction extends Action { * @return Project settings service */ private ProjectSettingsService getProjectSettings() { - return _projectSettingsService; + return _projectSettings; } /** @@ -264,53 +287,45 @@ public class SimulationContextAction extends Action { * @param projectSettingsService * project settings service */ - public void setProjectSettings(ProjectSettingsService projectSettingsService) { - _projectSettingsService = projectSettingsService; + public void setProjectSettings( + final ProjectSettingsService projectSettingsService) { + _projectSettings = projectSettingsService; } public ProjectSettingsService.Step getAttachedStep() { - // ---------------------------------------------- - return step; + return _step; } public List getContextsToBeApproved() { - // --------------------------------------------------------------- - return tocheck; + return _tocheck; } public SimulationContext getEdited() { - // ------------------------------------- - return edition; + return _edition; } public List getExistingContexts() { - // ----------------------------------------------------- - return existing; + return _existing; } public List getExistingNames() { - // ------------------------------------------------------ - return exisname; + return _exisname; } public List getSupportedLocales() { - // --------------------------------------------------------- - return existype; + return _existype; } public Set getIndexedElements() { - // ------------------------------------------------------ - return owner; + return _owner; } public int getSelection() { - // -------------------------- - return selection; + return _selection; } - public void setSelection(String index) { - // --------------------------------------- - selection = Integer.valueOf(index); + public void setSelection(final String index) { + _selection = Integer.valueOf(index); } /** @@ -329,7 +344,7 @@ public class SimulationContextAction extends Action { * the knowledgeElementService to set */ public void setKnowledgeElementService( - KnowledgeElementService knowledgeElementService) { + final KnowledgeElementService knowledgeElementService) { _knowledgeElementService = knowledgeElementService; } @@ -349,7 +364,7 @@ public class SimulationContextAction extends Action { * the simulationContextService to set */ public void setSimulationContextService( - SimulationContextService simulationContextService) { + final SimulationContextService simulationContextService) { _simulationContextService = simulationContextService; } @@ -368,12 +383,13 @@ public class SimulationContextAction extends Action { * @param searchService * the searchService to set */ - public void setSearchService(SearchService searchService) { + public void setSearchService(final SearchService searchService) { _searchService = searchService; } - + /** - * Get the menuProperty. + * Get the menuProperty. + * * @return the menuProperty */ public String getMenuProperty() { @@ -382,15 +398,17 @@ public class SimulationContextAction extends Action { /** * Set the menuProperty. + * * @param menuProperty * the menuProperty to set */ public void setMenuProperty(final String menuProperty) { this._menuProperty = menuProperty; } - + /** * Get the toolProperty. + * * @return the toolProperty */ public String getToolProperty() { @@ -399,14 +417,17 @@ public class SimulationContextAction extends Action { /** * Set the toolProperty. - * @param toolProperty the toolProperty to set + * + * @param toolProperty + * the toolProperty to set */ public void setToolProperty(final String toolProperty) { _toolProperty = toolProperty; } - + /** * Get the leftMenuProperty. + * * @return the leftMenuProperty */ public String getLeftMenuProperty() { @@ -415,7 +436,9 @@ public class SimulationContextAction extends Action { /** * Set the leftMenuProperty. - * @param leftMenuProperty the leftMenuProperty to set + * + * @param leftMenuProperty + * the leftMenuProperty to set */ public void setLeftMenuProperty(final String leftMenuProperty) { _leftMenuProperty = leftMenuProperty;