@Override
  public void setSymbols(List<List<String>> symbols) {
    log.info("set symbols called");

    clearTickSymbols();

    final List<TickParms> tp = new ArrayList<TickParms>();

    try {

      TickParms p;
      for (List<String> m : symbols) {
        p = new TickParms();
        p.setSymbol(m.get(0));
        p.setMinvol(Integer.parseInt(m.get(1)));
        p.setMaxvol(Integer.parseInt(m.get(2)));
        p.setPriceBasis(Double.parseDouble(m.get(3)));
        tp.add(p);
      }

    } catch (Exception e) {
      log.severe("caught exception parsing parms: " + e.getMessage());
    }

    log.info(String.format("calling setSymbols with %d symbols\n", tp.size()));
    try {
      ctx.getBean(TickGenerator.class).setSymbols(tp.toArray(new TickParms[] {}));
    } catch (Exception e) {
      log.severe("caught exception setting parms: " + e.getMessage());
    }
  }
  protected File savePageSourceToFile(String fileName, WebDriver webdriver, boolean retryIfAlert) {
    File pageSource = new File(reportsFolder, fileName + ".html");

    try {
      writeToFile(webdriver.getPageSource(), pageSource);
    } catch (UnhandledAlertException e) {
      if (retryIfAlert) {
        try {
          Alert alert = webdriver.switchTo().alert();
          log.severe(e + ": " + alert.getText());
          alert.accept();
          savePageSourceToFile(fileName, webdriver, false);
        } catch (Exception unableToCloseAlert) {
          log.severe("Failed to close alert: " + unableToCloseAlert);
        }
      } else {
        printOnce("savePageSourceToFile", e);
      }
    } catch (UnreachableBrowserException e) {
      writeToFile(e.toString(), pageSource);
      return pageSource;
    } catch (Exception e) {
      writeToFile(e.toString(), pageSource);
      printOnce("savePageSourceToFile", e);
    }
    return pageSource;
  }
  public void run() {
    String fileName;
    boolean verify_checksum;
    ResponseCallbackOpen cb = new ResponseCallbackOpen(mComm, mEvent);

    try {

      if (mEvent.payload.remaining() < 2) throw new ProtocolException("Truncated message");

      int version = (int) mEvent.payload.get();
      if (version != VERSION)
        throw new ProtocolException(
            "Open parameters version mismatch, expected " + VERSION + ", got " + version);

      int encoding_length = Serialization.DecodeVInt32(mEvent.payload);
      int start_position = mEvent.payload.position();

      int flags = mEvent.payload.getInt();
      int bufferSize = mEvent.payload.getInt();

      if ((fileName = Serialization.DecodeVStr(mEvent.payload)) == null)
        throw new ProtocolException("Filename not properly encoded in request packet");

      if ((mEvent.payload.position() - start_position) < encoding_length)
        mEvent.payload.position(start_position + encoding_length);

      mBroker.Open(cb, fileName, flags, bufferSize);

    } catch (Exception e) {
      int error = cb.error(Error.PROTOCOL_ERROR, e.getMessage());
      log.severe("Protocol error (OPEN) - " + e.getMessage());
      if (error != Error.OK)
        log.severe("Problem sending (OPEN) error back to client - " + Error.GetText(error));
    }
  }
Beispiel #4
0
 @Override
 public String update(Object obj) {
   Connection cn;
   PreparedStatement pst;
   String sql;
   String sqlresp = null;
   MstGasto gasto = (MstGasto) obj;
   try {
     Class.forName(bd.getDriver());
     cn = DriverManager.getConnection(bd.getUrl(), bd.getUser(), bd.getPasswd());
     sql =
         "update mst_tipo_gastos set desc_gasto=?, cod_cta_conta=?, valor_gasto=?, fecha_creacion=? cod_usuario=? activo=? where cod_residencial=? and corr_gasto=?";
     pst = cn.prepareStatement(sql);
     pst.setString(1, gasto.getDesc_gasto());
     pst.setString(2, gasto.getCod_cta_conta());
     pst.setDouble(3, gasto.getValor_gasto());
     pst.setDate(4, gasto.getFecha_creacion());
     pst.setString(5, gasto.getCod_usuario());
     pst.setString(6, gasto.getActivo());
     pst.setInt(7, gasto.getCod_residencial());
     pst.setInt(8, gasto.getCorr_gasto());
     int registro = pst.executeUpdate();
     sqlresp = registro + " registro ha sido modificado.";
     pst.close();
     cn.close();
   } catch (SQLException e) {
     log.severe(e.toString());
   } catch (Exception e) {
     log.severe(e.toString());
   }
   return sqlresp;
 }
Beispiel #5
0
 @Override
 public String create(Object obj) {
   Connection cn;
   PreparedStatement pst;
   String sql;
   String sqlresp = null;
   MstGasto gasto = (MstGasto) obj;
   try {
     Class.forName(bd.getDriver());
     cn = DriverManager.getConnection(bd.getUrl(), bd.getUser(), bd.getPasswd());
     sql = "insert into mst_tipo_gastos values (?, ?, ?, ?, ?, ?, ?, ?)";
     pst = cn.prepareStatement(sql);
     pst.setInt(1, gasto.getCod_residencial());
     pst.setInt(2, gasto.getCorr_gasto());
     pst.setString(3, gasto.getDesc_gasto());
     pst.setString(4, gasto.getCod_cta_conta());
     pst.setDouble(5, gasto.getValor_gasto());
     pst.setDate(6, gasto.getFecha_creacion());
     pst.setString(7, gasto.getCod_usuario());
     pst.setString(8, gasto.getActivo());
     int registro = pst.executeUpdate();
     sqlresp = registro + " registro ha sido agregado.";
     pst.close();
     cn.close();
   } catch (SQLException e) {
     log.severe(e.toString());
   } catch (Exception e) {
     log.severe(e.toString());
   }
   return sqlresp;
 }
  private void convert(File source, NavigationFormat format, File target) throws IOException {
    NavigationFileParser parser = new NavigationFileParser();
    if (!parser.read(source)) {
      log.severe("Could not read source '" + source.getAbsolutePath() + "'");
      logFormatNames(NavigationFormats.getReadFormatsSortedByName());
      System.exit(20);
    }

    if (format.isSupportsMultipleRoutes()) {
      parser.write(parser.getAllRoutes(), (MultipleRoutesFormat) format, target);
    } else {
      int fileCount =
          NavigationFileParser.getNumberOfFilesToWriteFor(parser.getTheRoute(), format, false);
      File[] targets =
          Files.createTargetFiles(
              target, fileCount, format.getExtension(), format.getMaximumFileNameLength());
      for (File t : targets) {
        if (t.exists()) {
          log.severe("Target '" + t.getAbsolutePath() + "' already exists; stopping.");
          System.exit(13);
        }
      }
      parser.write(parser.getTheRoute(), format, false, false, targets);
    }
  }
  public ArrayList<Statement> readQueries(File sql) {

    ArrayList<Statement> queries = new ArrayList<Statement>();

    try {

      FileReader fr = new FileReader(sql);
      CCJSqlParser parser = new CCJSqlParser(fr);
      Statement stmt;

      try {
        while ((stmt = parser.Statement()) != null) {
          if ((stmt instanceof CreateTable) || (stmt instanceof Select)) {
            queries.add(stmt);
          } else {
            logger.warning("PANIC! I don't know how to handle: ");
            logger.warning("" + stmt);
          }
        }
      } catch (ParseException e) {
        logger.severe("PARSE EXCEPTION IN READING FILE: " + sql);
        e.printStackTrace();
      }
    } catch (FileNotFoundException e) {
      logger.severe("SQL FILE NOT FOUND: " + sql);
      e.printStackTrace();
    }

    return queries;
  }
  /**
   * Executes the sql sentence created by <code>getSql</code>.
   *
   * @param values the values
   * @return the list< map< string, object>>
   */
  protected List<Map<String, Object>> resolveLookups(Object[] values) {
    List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();

    try {
      IManagerBean bean = getForeignManagerBean();
      Criteria criteria = getCriteria(bean, values);
      List<ITransferObject> list = bean.getList(criteria);
      if (list.size() > 0) {
        List<String> alias = getAlias();
        for (ITransferObject to : list) {
          result.add(getToMap(to, alias));
        }
      }
    } catch (ManagerBeanException e) {
      LOGGER.severe(e.getMessage());
    } catch (IllegalAccessException e) {
      LOGGER.severe(e.getMessage());
    } catch (InvocationTargetException e) {
      LOGGER.severe(e.getMessage());
    } catch (NoSuchMethodException e) {
      LOGGER.severe(e.getMessage());
    } catch (ExpressionException e) {
      LOGGER.severe(e.getMessage());
    }

    return result;
  }
  /**
   * Load the image located at URL.
   *
   * @param url URL where the image file is located.
   * @return loaded image at path or url
   * @see java.io.File#toURI()
   */
  public static synchronized Image loadImage(URL url) {
    Image image = null;
    image = Toolkit.getDefaultToolkit().getImage(url);
    if (image != null) {
      s_tracker.addImage(image, 0);
      try {
        s_tracker.waitForAll();
      } catch (InterruptedException e) {
        log.severe("Url= " + url + " - " + e.getMessage());
        s_tracker.removeImage(image);
        image = null;
      } finally {
        if (image != null) s_tracker.removeImage(image);
        if (s_tracker.isErrorAny()) {
          log.severe("Tracker: " + s_tracker.getErrorsAny()[0]);
          image = null;
        }

        if (image != null) {
          if (image.getWidth(null) < 0 || image.getHeight(null) < 0) {
            log.severe("Image=0");
            image = null;
          }
        }
      }
    }
    return image;
  } //  loadImage
Beispiel #10
0
  private void initialize() {
    if (file == null) {
      File dbFolder = new File(dbLocation);

      if (dbName.contains("/") || dbName.contains("\\") || dbName.endsWith(".db")) {
        log.severe("The database name can not contain: /, \\, or .db");
        return;
      }
      if (!dbFolder.exists()) {
        dbFolder.mkdir();
      }

      file = new File(dbFolder.getAbsolutePath() + File.separator + dbName + ".db");
    }

    try {
      Class.forName("org.sqlite.JDBC");
      connection = DriverManager.getConnection("jdbc:sqlite:" + file.getAbsolutePath());
      return;
    } catch (SQLException ex) {
      log.severe("SQLite exception on initialize " + ex);
    } catch (ClassNotFoundException ex) {
      log.severe("You need the SQLite library " + ex);
    }
  }
Beispiel #11
0
  /**
   * Execute an insert statement
   *
   * @param query
   */
  public long insert(String query) {
    if (PreciousStones.getInstance().getSettingsManager().isDebugsql()) {
      PreciousStones.getLog().info(query);
    }

    try {
      Statement statement = getConnection().createStatement();
      ResultSet keys = null;

      try {
        statement.executeUpdate(query);
        keys = statement.executeQuery("SELECT last_insert_rowid()");
      } finally {
        if (keys != null) {
          if (keys.next()) {
            return keys.getLong(1);
          }
        }
        statement.close();
        return 0;
      }
    } catch (SQLException ex) {
      if (!ex.toString().contains("not return ResultSet")) {
        log.severe("Error at SQL INSERT Query: " + ex);
        log.severe("Query: " + query);
      }
    }

    return 0;
  }
 @Override
 public void contextInitialized(ServletContextEvent sce) {
   ParallelInit.loggerAgentThread = new LoggerAgentThread(sce.getServletContext());
   log.info("registering to all inbound XMPP messages.. ");
   ArrayList<AdapterConfig> adapters =
       AdapterConfig.findAdapters(AdapterAgent.ADAPTER_TYPE_XMPP, null, null);
   XMPPServlet xmppServlet = new XMPPServlet();
   for (AdapterConfig adapterConfig : adapters) {
     try {
       xmppServlet.listenForIncomingChats(adapterConfig);
     } catch (XMPPException e) {
       log.severe(
           "Exception thrown while trying to register inbound XMPP service for: "
               + adapterConfig.getMyAddress());
     }
   }
   log.info("registering to all inbound Email messages.. ");
   adapters = AdapterConfig.findAdapters(AdapterAgent.ADAPTER_TYPE_EMAIL, null, null);
   for (AdapterConfig adapterConfig : adapters) {
     if (!adapterConfig.getMyAddress().endsWith("appspotmail.com")) {
       MailServlet mailServlet = new MailServlet(adapterConfig);
       try {
         mailServlet.listenForIncomingEmails();
       } catch (MessagingException e) {
         log.severe(
             "Exception thrown while trying to register inbound Email service for: "
                 + adapterConfig.getMyAddress());
       }
     }
   }
 }
  /**
   * Convience method for removing multiple buddies
   *
   * @param buddyList List of AIMBuddy
   */
  public void removeBuddies(List buddyList) {
    // make a list of buddys for each "group"
    Map groupMap = createGroupMap(buddyList);

    // iterate over the groups and remove the buddies
    Iterator groupIter = groupMap.keySet().iterator();
    while (groupIter.hasNext()) {
      String group = (String) groupIter.next();
      String currentlist = "toc2_remove_buddy";
      List groupList = (List) groupMap.get(group);
      for (int i = 0; i < groupList.size(); i++) {
        AIMBuddy buddy = (AIMBuddy) groupList.get(i);
        buddyHash.remove(imNormalize(buddy.getName()));
        currentlist += " " + imNormalize(buddy.getName());
        if (currentlist.length() > 1800) {
          try {
            frameSend(currentlist + " " + group + "\0");
            currentlist = "toc2_remove_buddy";
          } catch (IOException e) {
            e.printStackTrace();
            logger.severe("ERROR removing buddies.");
          }
        }
      }
      // remove the left overs (if any)
      if (currentlist.length() > "toc2_remove_buddy".length()) {
        try {
          frameSend(currentlist + " " + group + "\0");
        } catch (IOException e) {
          e.printStackTrace();
          logger.severe("ERROR adding buddies.");
        }
      }
    }
  }
 @Override
 public void run() {
   ActiveProcessManager.setActiveProcessManager(processManager);
   String line;
   try {
     while ((line = reader.readLine()) != null) {
       if (line.startsWith("[ERROR]")) {
         LOGGER.severe(line);
       } else if (line.startsWith("[WARNING]")) {
         LOGGER.warning(line);
       } else {
         LOGGER.info(line);
       }
     }
   } catch (final IOException e) {
     if (e.getMessage().contains("No such file or directory")
         || // For *nix/Mac
         e.getMessage().contains("CreateProcess error=2")) { // For Windows
       LOGGER.severe(
           "Could not locate Maven executable; please ensure mvn command is in your path");
     }
   } finally {
     IOUtils.closeQuietly(reader);
     ActiveProcessManager.clearActiveProcessManager();
   }
 }
  public void run() {
    int fd;
    ResponseCallback cb = new ResponseCallback(mComm, mEvent);

    try {

      if (mEvent.payload.remaining() < 2) throw new ProtocolException("Truncated message");

      int version = (int) mEvent.payload.get();
      if (version != VERSION)
        throw new ProtocolException(
            "Close parameters version mismatch, expected " + VERSION + ", got " + version);

      int encoding_length = Serialization.DecodeVInt32(mEvent.payload);
      int start_position = mEvent.payload.position();

      fd = mEvent.payload.getInt();

      if ((mEvent.payload.position() - start_position) < encoding_length)
        mEvent.payload.position(start_position + encoding_length);

      mBroker.Close(cb, fd);

    } catch (Exception e) {
      int error = cb.error(Error.PROTOCOL_ERROR, e.getMessage());
      log.severe("Protocol error (CLOSE) - " + e.getMessage());
      if (error != Error.OK)
        log.severe("Problem sending (CLOSE) error back to client - " + Error.GetText(error));
    }
  }
 private void buildHierarchyDOM() {
   TransformerFactory factory = TransformerFactory.newInstance();
   StreamSource src =
       new StreamSource(
           this.getServletContext()
               .getResourceAsStream("/WEB-INF/classes/gpt/search/browse/ownerHierarchy.xml"));
   log.info("initializing src from stream " + src);
   try {
     Transformer t = factory.newTransformer();
     dom = new DOMResult();
     t.transform(src, dom);
     // now go thru tree, setting up the query attribute for each node
     Node tree = dom.getNode();
     NodeList children = tree.getChildNodes();
     log.info("dom tree contains " + children.getLength() + " nodes");
     for (int i = 0; i < children.getLength(); i++) {
       Node child = children.item(i);
       if (child.getNodeType() == Node.ELEMENT_NODE) {
         Element e = (Element) child;
         String query = computeQuery(e);
         e.setAttribute("query", query);
       }
     }
   } catch (Exception e) {
     log.severe("Could not init ownerHierarchy because exception thrown:");
     StringWriter sw = new StringWriter();
     e.printStackTrace(new PrintWriter(sw));
     log.severe(sw.toString());
   }
 }
Beispiel #17
0
  /** Called after OK to verify data before closing. */
  @Override
  public boolean verifyData() {
    result = null;
    try {
      String option = getSelectedRadio();
      if (option.equals("File")) {
        File f = new File(getEntryText("File"));
        if (f.canWrite()) result = f;
        else throw new MalformedURLException("File is not writable");
      } else if (option.equals("Network")) {
        String host = getEntryText("Host");
        String name = getEntryText("Name");
        if (host.equals("") || name.equals(""))
          throw new MalformedURLException("Need a hostname and database name");

        result = host + "/" + name;
      }
    } catch (MalformedURLException e) {
      log.severe("Can't use database source: " + e.getMessage());
    } catch (Exception e) {
      log.severe("Bad data in DatabaseDialog: " + e);
    }

    return (result != null);
  }
  @Override
  public void layout(
      final String name,
      final Dimension height,
      final Dimension width,
      final Orientation orientation) {
    final Document document = newDocumentBuilder().newDocument();

    final Element layoutElem = document.createElement("LinearLayout");
    layoutElem.setAttribute("xmlns:android", ANDROID_NS);
    layoutElem.setAttribute("android:layout_height", height.value());
    layoutElem.setAttribute("android:layout_width", width.value());
    layoutElem.setAttribute("android:orientation", orientation.value());
    document.appendChild(layoutElem);

    final String layoutPath =
        pathResolver.getFocusedIdentifier(Path.ROOT, LAYOUT_PATH + SEP + name + XML_EXTENSION);
    if (fileManager.exists(layoutPath)) {
      LOGGER.severe("Layout '" + name + "' already exists");
      return;
    }
    final MutableFile file = fileManager.createFile(layoutPath);
    final OutputStream output = file.getOutputStream();
    XmlUtils.writeFormattedXml(output, document);
    try {
      output.close();
    } catch (IOException e) {
      LOGGER.severe("Error closing stream: " + e.getMessage());
      return;
    }
    //        fileManager.createOrUpdateTextFileIfRequired(layoutPath,
    //                XmlUtils.nodeToString(document), true);
  }
Beispiel #19
0
  /**
   * Genera una cadena representativa del &aacute;rbol que recibe.
   *
   * @param tree &Aacute;rbol que se desea representar.
   * @param linePrefx Prefijo de cada l&iacute;nea de firma (por defecto, cadena vac&iacute;a).
   * @param identationString Cadena para la identaci&oacute;n de los nodos de firma (por defecto,
   *     tabulador).
   * @return Cadena de texto.
   */
  public static String showTreeAsString(
      final AOTreeModel tree, final String linePrefx, final String identationString) {

    if (tree == null || tree.getRoot() == null) {
      LOGGER.severe("Se ha proporcionado un arbol de firmas vacio"); // $NON-NLS-1$
      return null;
    }

    if (!(tree.getRoot() instanceof AOTreeNode)) {
      LOGGER.severe(
          "La raiz del arbol de firmas no es de tipo DafaultMutableTreeNode"); //$NON-NLS-1$
      return null;
    }

    final StringBuilder buffer = new StringBuilder();

    // Transformamos en cadenas de texto cada rama que surja del nodo raiz
    // del arbol
    final AOTreeNode root = (AOTreeNode) tree.getRoot();
    for (int i = 0; i < root.getChildCount(); i++) {
      archiveTreeNode(
          root.getChildAt(i),
          0,
          linePrefx != null ? linePrefx : "",
          identationString != null ? identationString : "\t",
          buffer); //$NON-NLS-1$//$NON-NLS-2$
    }

    return buffer.toString();
  }
  @Override
  public Environment setUp(AbstractBuild build, Launcher launcher, BuildListener listener)
      throws IOException, InterruptedException {
    final ParametersAction origParamsAction = build.getAction(ParametersAction.class);
    if (origParamsAction == null) {
      // nothing we have to do
      return new Environment() {};
    }

    if (build.getProject().isConcurrentBuild()
        && !nodeParameterDefinition.isTriggerConcurrentBuilds()) {
      final String msg =
          Messages.BuildWrapper_param_not_concurrent(nodeParameterDefinition.getName());
      LOGGER.severe(msg);
      throw new IllegalStateException(msg);
    } else if (!build.getProject().isConcurrentBuild()
        && nodeParameterDefinition.isTriggerConcurrentBuilds()) {
      final String msg =
          Messages.BuildWrapper_project_not_concurrent(nodeParameterDefinition.getName());
      LOGGER.severe(msg);
      throw new IllegalStateException(msg);
    }

    // trigger builds concurrent
    if (build.getProject().isConcurrentBuild()) {
      triggerAllBuildsConcurrent(build, listener);
      return new Environment() {};
    }

    // trigger one build after the other
    return new TriggerNextBuildEnvironment();
  }
Beispiel #21
0
  private boolean isValidId(String propertyName, int maxSize) {
    logger.info("check -D" + propertyName);
    String value = systemProperty.getProperty(propertyName);
    if (value == null) {
      logger.severe("-D" + propertyName + " is null. value:null");
      return false;
    }
    // blanks not permitted around value
    value = value.trim();
    if (value.isEmpty()) {
      logger.severe("-D" + propertyName + " is empty. value:''");
      return false;
    }

    if (!IdValidateUtils.validateId(value, maxSize)) {
      logger.severe(
          "invalid Id. "
              + propertyName
              + " can only contain [a-zA-Z0-9], '.', '-', '_'. maxLength:"
              + maxSize
              + " value:"
              + value);
      return false;
    }
    if (logger.isLoggable(Level.INFO)) {
      logger.info("check success. -D" + propertyName + ":" + value + " length:" + getLength(value));
    }
    return true;
  }
Beispiel #22
0
 /**
  * Query the value of a parameter by its name
  *
  * @param name - String
  */
 public String getValue(String name) throws SQLException {
   if (this.con_ == null) {
     log_.severe("Connetion object null");
     throw new SQLException("Connection object not set.");
   }
   String sql = "select F_Value from T_Parameters where F_Name=?";
   String result = null;
   PreparedStatement stmt = null;
   ResultSet rs = null;
   try {
     stmt = con_.prepareStatement(sql);
     stmt.setString(1, name);
     rs = stmt.executeQuery();
     if (rs.next()) {
       result = rs.getString(1);
     }
   } catch (SQLException e) {
     log_.severe(e.toString());
   } finally {
     try {
       if (rs != null) rs.close();
       if (stmt != null) stmt.close();
     } catch (SQLException x) {
     }
   }
   return result;
 }
Beispiel #23
0
 @Override
 public String delete(Object obj) {
   Connection cn;
   PreparedStatement pst;
   String sql;
   String sqlresp = null;
   MstGasto gasto = (MstGasto) obj;
   try {
     Class.forName(bd.getDriver());
     cn = DriverManager.getConnection(bd.getUrl(), bd.getUser(), bd.getPasswd());
     sql = "delete from mst_tipo_gastos where cod_residencial=? and corr_gasto=?";
     pst = cn.prepareStatement(sql);
     pst.setInt(1, gasto.getCod_residencial());
     pst.setInt(2, gasto.getCorr_gasto());
     int registro = pst.executeUpdate();
     sqlresp = registro + " registro ha sido eliminado.";
     pst.close();
     cn.close();
   } catch (SQLException e) {
     log.severe(e.toString());
   } catch (Exception e) {
     log.severe(e.toString());
   }
   return sqlresp;
 }
Beispiel #24
0
 /**
  * Query by primary key(s), and populate current instance.
  *
  * @param _name - String
  */
 public void queryByPrimaryKey(String _name) throws SQLException {
   if (this.con_ == null) {
     log_.severe("Connetion object null");
     throw new SQLException("Connection object not set.");
   }
   String sql = "select * from T_Parameters where F_Name=?";
   PreparedStatement stmt = null;
   ResultSet rs = null;
   try {
     stmt = con_.prepareStatement(sql);
     stmt.setString(1, _name);
     rs = stmt.executeQuery();
     if (rs.next()) {
       setName(rs.getString(1));
       setValue(rs.getString(2));
       setType(rs.getString(3));
     }
   } catch (SQLException e) {
     log_.severe(e.toString());
     throw e;
   } finally {
     try {
       if (rs != null) rs.close();
       if (stmt != null) stmt.close();
     } catch (SQLException x) {
     }
   }
 }
Beispiel #25
0
 @Override
 public List<MstGasto> read() {
   Connection cn;
   PreparedStatement pst;
   ResultSet rs;
   String sql;
   List<MstGasto> lst = new ArrayList();
   try {
     Class.forName(bd.getDriver());
     cn = DriverManager.getConnection(bd.getUrl(), bd.getUser(), bd.getPasswd());
     sql = "select * from mst_tipo_gastos order by corr_gasto";
     pst = cn.prepareStatement(sql);
     rs = pst.executeQuery();
     while (rs.next()) {
       lst.add(
           new MstGasto(
               rs.getInt("cod_residencial"),
               rs.getInt("corr_gasto"),
               rs.getString("desc_gasto"),
               rs.getString("cod_cta_conta"),
               rs.getDouble("valor_gasto"),
               rs.getDate("fecha_creacion"),
               rs.getString("cod_usuario"),
               rs.getString("activo")));
     }
     rs.close();
     pst.close();
     cn.close();
   } catch (SQLException e) {
     log.severe(e.toString());
   } catch (Exception e) {
     log.severe(e.toString());
   }
   return lst;
 }
  @Override
  public void processCalculations(final User u, final Entity point, final Value value)
      throws NimbitsException {

    final List<Entity> calculations =
        EntityServiceFactory.getInstance().getEntityByTrigger(u, point, EntityType.calculation);
    for (final Entity entity : calculations) {
      Calculation c = (Calculation) entity;
      try {

        final List<Entity> target =
            EntityServiceFactory.getInstance().getEntityByKey(u, c.getTarget(), EntityType.point);
        if (target.isEmpty()) {
          log.severe("Point target was null " + c.getTarget());
          log.severe(c.getFormula());
          log.severe("trigger: " + c.getTrigger());
          disableCalc(u, c);
        } else {
          log.info("Solving calc" + c.getFormula());
          final Value result = solveEquation(u, c);
          log.info("result" + result);
          ValueServiceFactory.getInstance().recordValue(u, target.get(0), result);
        }
      } catch (NimbitsException e1) {
        LogHelper.logException(this.getClass(), e1);
        disableCalc(u, c);
      }
    }
  }
Beispiel #27
0
  private void proposeMove(String queenName) {
    DFAgentDescription template = new DFAgentDescription();
    ServiceDescription sd = new ServiceDescription();
    sd.setType("Publish-queen");
    template.addServices(sd);

    try {
      DFAgentDescription[] result = DFService.search(this, template);
      if (result != null && result.length > 0) {
        ACLMessage msg = new ACLMessage(ACLMessage.PROPOSE);
        for (int i = 0; i < result.length; ++i) {
          if (result[i].getName().getLocalName().equals(queenName)) {
            msg.addReceiver(result[i].getName());
          }
        }

        msg.setContent(ChessCommand.MOVE);
        send(msg);

      } else {
        log.severe("Queen is not registred or not available");
      }

    } catch (FIPAException e) {
      log.severe(e.getMessage());
    }
  }
Beispiel #28
0
  public void storeClaimBackup(Claim claim, World world) {
    int baseX = getBase(claim.getX());
    long topX = claim.getX() >= 0 ? baseX + claimSize : baseX - claimSize;

    int baseZ = getBase(claim.getZ());
    long topZ = claim.getZ() >= 0 ? baseZ + claimSize : baseZ - claimSize;

    int maxY = world.getMaxHeight();

    Properties props = new Properties();

    for (int y = 0; y <= maxY; y++) {
      for (int z = baseZ; z <= topZ; z++) {
        for (int x = baseX; x <= topX; x++) {
          Block blockAt = world.getBlockAt(x, y, z);
          props.put(
              String.format("%d,%d,%d", x, y, z),
              String.format("%d:%d", blockAt.getTypeId(), blockAt.getData()));
        }
      }
    }

    File file = new File(backupFolder, String.format("claim-%d.xml"));

    try {
      props.storeToXML(
          new FileOutputStream(file), String.format("Claim backup for claim %d", claim.getId()));
    } catch (FileNotFoundException e) {
      logger.severe("Could not write backup to file" + file.getName());
    } catch (IOException e) {
      logger.severe("Could not write backup to file" + file.getName() + ": " + e.getMessage());
    }
  }
Beispiel #29
0
  public void setBuildOpts(Workspace workspace) throws AbortException {

    ClientHelper p4 = new ClientHelper(credential, listener, client);

    try {
      // setup the client workspace to use for the build.
      if (!p4.setClient(workspace)) {
        String err = "Undefined workspace: " + workspace.getFullName();
        logger.severe(err);
        listener.error(err);
        throw new AbortException(err);
      }

      // fetch and calculate change to sync to or review to unshelve.
      status = getStatus(workspace);
      head = p4.getClientHead();
      review = getReview(workspace);
      buildChange = getBuildChange(workspace);

    } catch (Exception e) {
      String err = "Unable to setup workspace: " + e;
      logger.severe(err);
      listener.error(err);
      throw new AbortException(err);
    } finally {
      p4.disconnect();
    }
  }
Beispiel #30
0
  private void prepareProcessing() throws ProcessorException, IOException {
    _logger.info(ProcessorConstants.LOG_MSG_START_REQUEST);

    loadRequestParams();

    // create a vector of input bands
    // ------------------------------
    loadInputProduct();

    // create a bitmask expression for input
    // -------------------------------------
    createBitmaskExpression();

    installAuxdata();
    File smacAuxDir = getAuxdataInstallDir();

    String auxPathString = smacAuxDir.toString();
    try {
      _coeffMgr = new SensorCoefficientManager(smacAuxDir.toURI().toURL());
      _logger.fine(SmacConstants.LOG_MSG_AUX_DIR + auxPathString);
    } catch (IOException e) {
      _logger.severe(SmacConstants.LOG_MSG_AUX_ERROR + auxPathString);
      _logger.severe(e.getMessage());
    }
  }