Package gov.nysenate.openleg.model

Examples of gov.nysenate.openleg.model.Change


            try {
                // Extract object descriptors from the entry key
                String key = entry.getKey();
                String otype = key.split("/")[1];
                String oid = key.split("/")[2];
                Change change = entry.getValue();
                logger.debug("Indexing "+change.getStatus()+" "+otype+": "+oid);

                // We don't currently index agendas; meetings get their own entries
                // and meeting votes are attached to bills
                if (otype.equals("agenda")) continue;

                if (change.getStatus() == Storage.Status.DELETED) {
                    if(otype.equals("bill")) {
                        // When a bill is deleted, also remove its sub-documents
                        lucene.deleteDocumentsByQuery("otype:action AND billno:" + oid);
                        lucene.deleteDocumentsByQuery("otype:vote AND billno:" + oid);
                        lucene.deleteDocumentById(oid);
View Full Code Here


        DataSource datasource = Application.getDB().getDataSource();
        QueryRunner run = new QueryRunner(datasource);
        try {
            run.update("BEGIN");
            for(Entry<String, Change> entry: entries) {
                Change change = entry.getValue();
                run.update("INSERT INTO changelog (otype, oid, time, status) VALUES (?, ?, ?, ?) ON DUPLICATE KEY UPDATE oid = ?",
                        change.getOtype(), change.getOid(), change.getTime(), change.getStatus().name(), change.getOid());
            }
            run.update("COMMIT");
        }
        catch (SQLException e) {
            e.printStackTrace();
View Full Code Here

                        Date date = dateFormat.parse(changeLine.group(3));
                        Matcher keyMatcher = keyPattern.matcher(changeLine.group(1));
                        if (keyMatcher.find()) {
                            String otype = keyMatcher.group(2);
                            String oid = keyMatcher.group(3);
                            changeLog.put(changeLine.group(1), new Change(oid, otype, Storage.Status.valueOf(changeLine.group(2).toUpperCase()), date));
                        }
                        else {
                            logger.error("Invalid key format for changelog line: "+line);
                        }
                    }
View Full Code Here

        }

        String otype = keyMatcher.group(2);
        String oid = keyMatcher.group(3);

        Change change = changeLog.get(key);
        if (change == null) {
            changeLog.put(key, new Change(oid, otype, storage.status(key), ChangeLogger.datetime));
        }
        else if (change.getStatus() == Status.DELETED) {
            // If it was previously deleted, make it new
            changeLog.put(key, new Change(oid, otype, Status.NEW, ChangeLogger.datetime));
        }
        else if (change.getStatus() != Status.NEW) {
            // Don't change a status marked as NEW
            changeLog.put(key, new Change(oid, otype, Status.MODIFIED, ChangeLogger.datetime));
        }
    }
View Full Code Here

        }
    }

    public static void delete(String key, Storage storage)
    {
        Change change = changeLog.get(key);
        if (change != null) {
            // Already a change to this key waiting to be pushed to services.
            if (change.getStatus() == Status.NEW) {
                // If new, just remove it.
                changeLog.remove(key);
            } else if (change.getStatus() == Status.MODIFIED){
                // Can't process a Modification since its file has been deleted.
                change.setStatus(Status.DELETED);
            }
        } else {
            // Otherwise make sure to leave a trace of the object
            Matcher keyMatcher = keyPattern.matcher(key);
            if (keyMatcher.find()) {
                String otype = keyMatcher.group(2);
                String oid = keyMatcher.group(3);
                changeLog.put(key, new Change(oid, otype, Status.DELETED, ChangeLogger.datetime));
            }
            else {
                logger.error("Invalid changelog key: "+key);
            }
        }
View Full Code Here

        public ArrayList<Change> handle(ResultSet results) throws SQLException
        {
            ArrayList<Change> changes = new ArrayList<Change>();
            while(results.next()) {
                    try {
                        changes.add(new Change(
                            results.getString("oid"),
                            results.getString("otype"),
                            Storage.Status.valueOf(results.getString("status")),
                            mysqlDateFormat.parse(results.getString("time"))
                        ));
View Full Code Here

TOP

Related Classes of gov.nysenate.openleg.model.Change

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.