/** * Generates handles response. This is were we would pass stuff to cli or gui, etc * * @param n the processed policy object * @return the policyObjected as accepted by user (potentially modified */ public PolicyObject userResponse(PolicyObject n) { if ((parseAct(genProps.getProperty("userResponse", null)) == null) && !Boolean.parseBoolean(genProps.getProperty("blanketAccept", "false"))) { return userInterface.userResponse(n); } else { if (Boolean.parseBoolean(genProps.getProperty("blanketAccept", "false"))) { return n.setAction(n.getAction().setOverride(true)); } else { return n.setAction(parseAct(genProps.getProperty("userResponse", null))); } } }
private static Map<String, String> nodeAllocationToMap(AssociationEntry entry) { final HashMap<String, String> map = new HashMap(8); map.put(FIELD_HOSTNAME, entry.getHostname()); map.put(FIELD_IP, entry.getIpAddress()); map.put(FIELD_MAC, entry.getMac()); map.put(FIELD_BROADCAST, entry.getBroadcast()); map.put(FIELD_SUBNET_MASK, entry.getSubnetMask()); map.put(FIELD_GATEWAY, entry.getGateway()); map.put(FIELD_IN_USE, Boolean.toString(entry.isInUse())); map.put(FIELD_EXPLICIT_MAC, Boolean.toString(entry.isExplicitMac())); return map; }
/** * A constructor permitting a user interface class to launch everything and be in control. * * @param args any commandline arguements * @param ui the known UserIO object * @throws Exception Mostly from loadWeights, but should also happen for loadFromConfig */ public Gio(String[] args, UserIO ui) throws Exception { userInterface = ui; genProps = loadFromConfig("./PrivacyAdviser.cfg"); loadCLO(args); // TODO add method to check validity of genProps (after each file load, clo load, and ui load). if ((genProps.getProperty("genConfig") != null) && (genProps.getProperty("genConfig") != "./PrivacyAdvisor.cfg")) { System.err.println("clo config call"); genProps = loadFromConfig(genProps.getProperty("genConfig")); // TODO merge, not override loadCLO(args); } // start the logger logger = startLogger( genProps.getProperty("loglocation", "./LOG.txt"), genProps.getProperty("loglevel", "INFO")); if (userInterface == null) { selectUI(genProps.getProperty("userIO")); } selectPDB(genProps.getProperty("policyDB")); // load the weights configuration file origWeights = new Properties(); origWeights = loadWeights(); if (Boolean.parseBoolean(genProps.getProperty("useNet", "false"))) { startNetwork(); } else { nr = null; } }
/** * Loads the case history into cache. This is where the background database chosen. * * @param dLoc the location of the database */ public void loadDB() { try { // TODO what about if we want to create a new db? if (!Boolean.parseBoolean(genProps.getProperty("newDB"))) { pdb.loadDB(); } } catch (Exception e) { System.err.println("Something wrong with loading DB"); } try { loadCLPolicies(); } catch (Exception e) { System.err.println("Error. Probably wrong path to P3P folder"); } }
private static Params parse(String[] args) { Options options = generateCommandlineOptions(); CommandLineParser parser = new PosixParser(); Params params = new Params(); try { CommandLine cmd = parser.parse(options, args); String value; if (cmd.hasOption("input")) { params.input = cmd.getOptionValue("input"); } if (cmd.hasOption("maxIter")) { value = cmd.getOptionValue("maxIter"); params.maxIter = Integer.parseInt(value); } if (cmd.hasOption("tol")) { value = cmd.getOptionValue("tol"); params.tol = Double.parseDouble(value); } if (cmd.hasOption("fitIntercept")) { value = cmd.getOptionValue("fitIntercept"); params.fitIntercept = Boolean.parseBoolean(value); } if (cmd.hasOption("regParam")) { value = cmd.getOptionValue("regParam"); params.regParam = Double.parseDouble(value); } if (cmd.hasOption("elasticNetParam")) { value = cmd.getOptionValue("elasticNetParam"); params.elasticNetParam = Double.parseDouble(value); } if (cmd.hasOption("testInput")) { value = cmd.getOptionValue("testInput"); params.testInput = value; } if (cmd.hasOption("fracTest")) { value = cmd.getOptionValue("fracTest"); params.fracTest = Double.parseDouble(value); } } catch (ParseException e) { printHelpAndQuit(options); } return params; }
public static void main(String args[]) throws ConfigurationException, IOException, WikiBrainException, DaoException { Options options = new Options(); // Number of Max Results(otherwise take from config) options.addOption( new DefaultOptionBuilder() .hasArg() .withLongOpt("max-results") .withDescription("maximum number of results") .create("r")); // Specify the Datasets options.addOption( new DefaultOptionBuilder() .hasArgs() .withLongOpt("gold") .withDescription("the set of gold standard datasets to train on") .create("g")); // Delete existing data models options.addOption( new DefaultOptionBuilder() .hasArg() .withLongOpt("delete") .withDescription( "delete all existing SR data for the metric and its submetrics (true or false, default is true)") .create("d")); // Specify the Metrics options.addOption( new DefaultOptionBuilder() .hasArg() .withLongOpt("metric") .withDescription("set a local metric") .create("m")); // Row and column ids for most similar caches options.addOption( new DefaultOptionBuilder() .hasArg() .withLongOpt("rowids") .withDescription("page ids for rows of cosimilarity matrices (implies -s)") .create("p")); options.addOption( new DefaultOptionBuilder() .hasArg() .withLongOpt("colids") .withDescription("page ids for columns of cosimilarity matrices (implies -s)") .create("q")); // build the cosimilarity matrix options.addOption( new DefaultOptionBuilder() .withLongOpt("cosimilarity") .withDescription("build cosimilarity matrices") .create("s")); // sets the mode options.addOption( new DefaultOptionBuilder() .withLongOpt("mode") .hasArg() .withDescription("mode: similarity, mostsimilar, or both") .create("o")); // add option for valid most similar ids options.addOption( new DefaultOptionBuilder() .withLongOpt("validMostSimilarIds") .withDescription("Set valid most similar ids") .create("y")); // when building pairwise cosine and ensembles, don't rebuild already built sub-metrics. options.addOption( new DefaultOptionBuilder() .withLongOpt("skip-built") .withDescription("Don't rebuild already built bmetrics (implies -d false)") .create("k")); // when building pairwise cosine and ensembles, don't rebuild already built sub-metrics. options.addOption( new DefaultOptionBuilder() .withLongOpt("fake") .withDescription("Create a fake gold standard for the language.") .create("f")); EnvBuilder.addStandardOptions(options); CommandLineParser parser = new PosixParser(); CommandLine cmd; try { cmd = parser.parse(options, args); } catch (ParseException e) { System.err.println("Invalid option usage: " + e.getMessage()); new HelpFormatter().printHelp("SRBuilder", options); return; } Env env = new EnvBuilder(cmd).build(); String metric = cmd.hasOption("m") ? cmd.getOptionValue("m") : null; SRBuilder builder = new SRBuilder(env, metric); if (cmd.hasOption("g")) { builder.setDatasetNames(Arrays.asList(cmd.getOptionValues("g"))); } if (cmd.hasOption("p")) { builder.setRowIdsFromFile(cmd.getOptionValue("p")); builder.setBuildCosimilarity(true); } if (cmd.hasOption("q")) { builder.setColIdsFromFile(cmd.getOptionValue("q")); builder.setBuildCosimilarity(true); } if (cmd.hasOption("y")) { builder.setValidMostSimilarIdsFromFile(cmd.getOptionValue("y")); } if (cmd.hasOption("s")) { builder.setBuildCosimilarity(true); } if (cmd.hasOption("k")) { builder.setSkipBuiltMetrics(true); builder.setDeleteExistingData(false); } if (cmd.hasOption("d")) { builder.setDeleteExistingData(Boolean.valueOf(cmd.getOptionValue("d"))); } if (cmd.hasOption("o")) { builder.setMode(Mode.valueOf(cmd.getOptionValue("o").toUpperCase())); } if (cmd.hasOption("l")) { builder.setLanguage(Language.getByLangCode(cmd.getOptionValue("l"))); } if (cmd.hasOption("r")) { builder.setMaxResults(Integer.valueOf(cmd.getOptionValue("r"))); } if (cmd.hasOption("f")) { builder.setCreateFakeGoldStandard(true); } builder.build(); }
/** * call the user interface's general configuration method if the userInit option is true, and a * user interface exists */ public void configUI() { if (Boolean.parseBoolean(genProps.getProperty("userInit", "false")) && !(userInterface == null)) { userInterface.user_init(genProps); } }
/** make menu bar a separate component */ private void buildMenuToolBar() { // get property manager PrideInspectorContext context = (PrideInspectorContext) getDesktopContext(); // create all the actions // file open action Icon openFileIcon = GUIUtilities.loadIcon(context.getProperty("open.file.icon.small")); String openFileDesc = context.getProperty("open.file.title"); String openFileTooltip = context.getProperty("open.file.tooltip"); PrideAction openFileAction = new OpenFileAction(openFileDesc, openFileIcon); // database open action Icon openDbIcon = GUIUtilities.loadIcon(context.getProperty("open.database.icon.small")); String openDbDesc = context.getProperty("open.database.title"); String openDbTooltip = context.getProperty("open.database.tooltip"); PrideAction openDbAction = new OpenDatabaseAction(openDbDesc, openDbIcon); // open reviewer Icon openReviewerIcon = GUIUtilities.loadIcon(context.getProperty("reviewer.download.icon.small")); String openReviewerDesc = context.getProperty("reviewer.download.title"); String openReviewerTooltip = context.getProperty("reviewer.download.tooltip"); PrideAction openReviewerAction = new OpenReviewAction(openReviewerDesc, openReviewerIcon); // close String closeDesc = context.getProperty("close.source.title"); String closeAllDesc = context.getProperty("close.all.soruce.title"); PrideAction closeAction = new CloseControllerAction(closeDesc, null); PrideAction closeAllAction = new CloseAllControllersAction(closeAllDesc, null); context.addPropertyChangeListenerToDataAccessMonitor((PropertyChangeListener) closeAction); context.addPropertyChangeListenerToDataAccessMonitor((PropertyChangeListener) closeAllAction); // try pride xml sample String openPrideXmlExampleDesc = context.getProperty("open.pride.xml.example.title"); File prideXmlExampleFile = getExampleFiles(context.getProperty("pride.inspector.pride.example.file")); java.util.List<File> prideXmlFiles = new ArrayList<File>(); if (prideXmlExampleFile != null) { prideXmlFiles.add(prideXmlExampleFile); } PrideAction openPrideXmlExampleAction = new OpenFileAction(openPrideXmlExampleDesc, null, prideXmlFiles); openPrideXmlExampleAction.setEnabled( prideXmlExampleFile != null && prideXmlExampleFile.exists()); // try mzml sample String openMzMLExampleDesc = context.getProperty("open.mzml.example.title"); File mzMLExampleFile = getExampleFiles(context.getProperty("pride.inspector.mzml.example.file")); java.util.List<File> mzMLFiles = new ArrayList<File>(); if (mzMLExampleFile != null) { mzMLFiles.add(mzMLExampleFile); } PrideAction openMzMLExampleAction = new OpenFileAction(openMzMLExampleDesc, null, mzMLFiles); openMzMLExampleAction.setEnabled(mzMLExampleFile != null && mzMLExampleFile.exists()); // help Icon helpIcon = GUIUtilities.loadIcon(context.getProperty("help.icon.small")); String helpDesc = context.getProperty("help.title"); String helpTooltip = context.getProperty("help.tooltip"); PrideAction helpAction = new OpenHelpAction(helpDesc, helpIcon); // faq String faqDesc = context.getProperty("faq.title"); PrideAction faqAction = new OpenFAQAction(faqDesc, null); // pride website String prideWeb = context.getProperty("open.pride.website.title"); String prideWebUrl = context.getProperty("pride.website"); PrideAction prideWebAction = new OpenUrlAction(prideWeb, null, prideWebUrl); // pride website String inspectorWeb = context.getProperty("open.pride.inspector.website.title"); String inspectorWebUrl = context.getProperty("pride.inspector.website"); PrideAction inspectorWebAction = new OpenUrlAction(inspectorWeb, null, inspectorWebUrl); // feedback String feedbackDesc = context.getProperty("feedback.title"); PrideAction feedBackAction = new FeedbackAction(feedbackDesc, null); // export String exportDesc = context.getProperty("export.title"); PrideAction exportAction = new ExportSpectrumAction(exportDesc, null); context.addPropertyChangeListenerToDataAccessMonitor((PropertyChangeListener) exportAction); // export identification String exportIdentDesc = context.getProperty("export.identification.title"); PrideAction exportIdentAction = new ExportIdentificationPeptideAction(exportIdentDesc, null); // export spectrum description String exportSpectrumDesc = context.getProperty("export.spectrum.desc.title"); PrideAction exportSpectrumDescAction = new ExportSpectrumDescAction(exportSpectrumDesc, null); // export identification description String exportIdentDescTitle = context.getProperty("export.identification.desc.title"); PrideAction exportIdentDescAction = new ExportIdentificationDescAction(exportIdentDescTitle, null); // export peptide description String exportPeptideDescTitle = context.getProperty("export.peptide.desc.title"); PrideAction exportPeptideAction = new ExportPeptideDescAction(exportPeptideDescTitle, null); // make experiment public String makeExpPublicTitle = context.getProperty("make.experiment.public.title"); PrideAction makeExpPublicAction = new MakeExperimentPublicAction(makeExpPublicTitle, null); String createReviewerTitle = context.getProperty("create.reviewer.title"); PrideAction createReviewerAction = new CreateReviewerAction(createReviewerTitle, null); // check update String updateDescTitle = context.getProperty("check.update.desc.title"); PrideAction updateAction = new UpdateAction(updateDescTitle, null); // about String aboutDesc = context.getProperty("about.title"); PrideAction aboutAction = new AboutAction(aboutDesc, null); // exit String exitDesc = context.getProperty("exit.title"); PrideAction exitAction = new ExitAction(exitDesc, null); // menu items menuBar = new JMenuBar(); // file menu JMenu fileMenu = MenuFactory.createMenu( "File", openFileAction, openDbAction, openReviewerAction, MenuFactory.ACTION_SEPARATOR, closeAction, closeAllAction, MenuFactory.ACTION_SEPARATOR, exitAction); fileMenu.setMnemonic(java.awt.event.KeyEvent.VK_F); menuBar.add(fileMenu); // try samples JMenu trySampleMenu = MenuFactory.createMenu("Examples", openPrideXmlExampleAction, openMzMLExampleAction); trySampleMenu.setMnemonic(java.awt.event.KeyEvent.VK_X); menuBar.add(trySampleMenu); // export menu JMenu exportMenu = MenuFactory.createMenu( "Export", exportAction, exportSpectrumDescAction, exportIdentAction, exportIdentDescAction, exportPeptideAction); exportMenu.setMnemonic(java.awt.event.KeyEvent.VK_E); menuBar.add(exportMenu); // curation menu boolean showCurationMenu = Boolean.parseBoolean(context.getProperty("include.curation.menu")); if (showCurationMenu) { JMenu curationMenu = MenuFactory.createMenu("Curation", makeExpPublicAction, createReviewerAction); curationMenu.setMnemonic(java.awt.event.KeyEvent.VK_C); menuBar.add(curationMenu); } // help menu JMenu helpMenu = MenuFactory.createMenu( "Help", helpAction, faqAction, MenuFactory.ACTION_SEPARATOR, prideWebAction, inspectorWebAction, MenuFactory.ACTION_SEPARATOR, feedBackAction, MenuFactory.ACTION_SEPARATOR, updateAction, aboutAction); helpMenu.setMnemonic(java.awt.event.KeyEvent.VK_H); menuBar.add(helpMenu); // add menus mainFrame.setJMenuBar(menuBar); // tool bar toolBar = new JToolBar(); // open file JButton openFileButton = new JButton(); openFileButton.setAction(openFileAction); openFileButton.setText(""); openFileButton.setToolTipText(openFileTooltip); openFileButton.setFocusable(false); toolBar.add(openFileButton); // open database JButton openDbButton = new JButton(); openDbButton.setAction(openDbAction); openDbButton.setText(""); openDbButton.setToolTipText(openDbTooltip); openDbButton.setFocusable(false); toolBar.add(openDbButton); // open reviewer download JButton openReviewerButton = new JButton(); openReviewerButton.setAction(openReviewerAction); openReviewerButton.setText(""); openReviewerButton.setToolTipText(openReviewerTooltip); openReviewerButton.setFocusable(false); toolBar.add(openReviewerButton); // separator toolBar.addSeparator(); // help JButton helpButton = new JButton(helpIcon); helpButton.setAction(helpAction); helpButton.setText(""); helpButton.setToolTipText(helpTooltip); helpButton.setFocusable(false); toolBar.add(helpButton); mainFrame.getContentPane().add(toolBar, BorderLayout.PAGE_START); }