Package gov.nysenate.openleg.model

Examples of gov.nysenate.openleg.model.BaseObject


                    }
                }
                else {
                    // Retrieve new/modified objects from storage so we can index them
                    Class<? extends BaseObject> objType = classMap.get(otype);
                    BaseObject obj = storage.get(key, objType);
                    if (obj.isPublished()) {
                        Document document = null;

                        if (otype.equals("bill")) {
                            // Regenerate all the bill sub-documents. Delete them all first to
                            // account for any removals or changes in the document oid. Add back
View Full Code Here


                jsonData = unwrapJson(jsonData);

                ApiType apiType = getApiType(type);
                Class<? extends BaseObject> clazz = apiType.clazz();

                BaseObject resultObj = null;
                try {
                    resultObj = mapper.readValue(jsonData, clazz);
                    result.setObject(resultObj);
                } catch (Exception e) {
                    logger.error("error binding:" + clazz.getName(), e);
                }

                if (resultObj == null)
                    continue;

                resultObj.setModifiedDate(new Date(result.getLastModified()));
                resultObj.setActive(result.isActive());

                String title = "";
                String summary = "";

                HashMap<String, String> fields = new HashMap<String, String>();
View Full Code Here

     * @param cls - The class interpret the value as.
     * @return - The object from storage.
     */
    public BaseObject get(String key, Class<? extends BaseObject> cls)
    {
        BaseObject value = null;
        if (memory.containsKey(key)) {
            logger.debug("Cache hit: "+key);
            value = memory.get(key);
        }
        else {
            logger.debug("Cache miss: "+key);
            File storageFile = getStorageFile(key);
            if (storageFile != null) {
                try {
                    if (cls == Bill.class) {
                        value = this.converter.readBill(storageFile);
                    }
                    else if (cls == Agenda.class) {
                        value = this.converter.readAgenda(storageFile);
                    }
                    else if (cls == Meeting.class) {
                        value = this.converter.readMeeting(storageFile);
                    }
                    else if (cls == Calendar.class) {
                        value = this.converter.readCalendar(storageFile);
                    }
                    else if (cls == Transcript.class) {
                        value = this.converter.readTranscript(storageFile);
                    }
                    else {
                        logger.error("Unable to read value of type "+cls.getName()+" from: "+storageFile);
                        return null;
                    }
                    value.setBrandNew(false);
                } catch (org.codehaus.jackson.JsonParseException e) {
                    logger.error("could not parse json", e);
                } catch (JsonMappingException e) {
                    logger.error("could not map json", e);
                } catch (IOException e) {
View Full Code Here

        // Remove existing file record.
        FileUtils.deleteQuietly(getUnpublishedFile(key));
        FileUtils.deleteQuietly(getPublishedFile(key));

        // If the value wasn't deleted, write it to file
        BaseObject value = memory.get(key);
        if (value != null) {
            File storageFile = value.isPublished() ? getPublishedFile(key) : getUnpublishedFile(key);

            try {
                FileUtils.forceMkdir(storageFile.getParentFile());
                if (value instanceof Bill) {
                    this.converter.write((Bill)value, storageFile);
                }
                else if (value instanceof Agenda) {
                    this.converter.write((Agenda)value, storageFile);
                }
                else if (value instanceof Meeting) {
                    this.converter.write((Meeting)value, storageFile);
                }
                else if (value instanceof Calendar) {
                    this.converter.write((Calendar)value, storageFile);
                }
                else if (value instanceof Transcript) {
                    this.converter.write((Transcript)value, storageFile);
                }
                else {
                    logger.error("Unable to write value of type "+value.getClass().getName()+": "+value.getOid());
                    return;
                }
            }
            catch (IOException e) {
                logger.error("Cannot open file for writing: "+storageFile, e);
View Full Code Here

        }
    }

    private void doSingleView(HttpServletRequest request, HttpServletResponse response, String format, String type, String id) throws ApiRequestException, IOException, ServletException
    {
        BaseObject object = (BaseObject)Application.getLucene().getSenateObject(id, type);

        if(object == null) {
            throw new ApiRequestException(TextFormatter.append("couldn't find id: ", id, " of type: ", type));
        }
        else {
View Full Code Here

TOP

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

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.