Package com.serotonin.m2m2.i18n

Examples of com.serotonin.m2m2.i18n.TranslatableJsonException


    public void jsonRead(JsonReader reader, JsonObject jsonObject) throws JsonException {
        super.jsonRead(reader, jsonObject);

        String xid = jsonObject.getString("XID");
        if (xid == null)
            throw new TranslatableJsonException("emport.error.eventType.missing.reference", "XID");
        ScheduledEventVO se = new ScheduledEventDao().getScheduledEvent(xid);
        if (se == null)
            throw new TranslatableJsonException("emport.error.eventType.invalid.reference", "XID", xid);
        scheduleId = se.getId();
    }
View Full Code Here


    @Override
    public void jsonRead(JsonReader reader, JsonObject jsonObject) throws JsonException {
        String username = jsonObject.getString("user");
        if (StringUtils.isBlank(username))
            throw new TranslatableJsonException("emport.error.missingValue", "user");
        User user = new UserDao().getUser(username);
        if (user == null)
            throw new TranslatableJsonException("emport.error.missingUser", username);
        userId = user.getId();

        JsonArray jsonDataPoints = jsonObject.getJsonArray("dataPoints");
        if (jsonDataPoints != null) {
            pointList.clear();
            DataPointDao dataPointDao = new DataPointDao();
            for (JsonValue jv : jsonDataPoints) {
                String xid = jv.toString();
                DataPointVO dpVO = dataPointDao.getDataPoint(xid);
                if (dpVO == null)
                    throw new TranslatableJsonException("emport.error.missingPoint", xid);
                pointList.add(dpVO);
            }
        }

        JsonArray jsonSharers = jsonObject.getJsonArray("sharingUsers");
View Full Code Here

    @Override
    public void jsonRead(JsonReader reader, JsonObject jsonObject) throws JsonException {
        String text = jsonObject.getString("attributeId");
        if (text == null)
            throw new TranslatableJsonException("emport.error.missing", "attributeId", ATTRIBUTE_CODES.getCodeList());
        attributeId = ATTRIBUTE_CODES.getId(text);
        if (!ATTRIBUTE_CODES.isValidId(attributeId))
            throw new TranslatableJsonException("emport.error.invalid", "attributeId", text,
                    ATTRIBUTE_CODES.getCodeList());
    }
View Full Code Here

    public void jsonRead(JsonReader reader, JsonObject jsonObject) throws JsonException {
        String text = jsonObject.getString("dataSourceXid");
        if (text != null) {
            DataSourceVO<?> ds = new DataSourceDao().getDataSource(text);
            if (ds == null)
                throw new TranslatableJsonException("emport.error.maintenanceEvent.invalid", "dataSourceXid", text);
            dataSourceId = ds.getId();
        }

        text = jsonObject.getString("alarmLevel");
        if (text != null) {
            alarmLevel = AlarmLevels.CODES.getId(text);
            if (!AlarmLevels.CODES.isValidId(alarmLevel))
                throw new TranslatableJsonException("emport.error.maintenanceEvent.invalid", "alarmLevel", text,
                        AlarmLevels.CODES.getCodeList());
        }

        text = jsonObject.getString("scheduleType");
        if (text != null) {
            scheduleType = TYPE_CODES.getId(text);
            if (!TYPE_CODES.isValidId(scheduleType))
                throw new TranslatableJsonException("emport.error.maintenanceEvent.invalid", "scheduleType", text,
                        TYPE_CODES.getCodeList());
        }
    }
View Full Code Here

        String xid = jsonObject.getString("sourcePointId");
        if (xid != null) {
            DataPointVO vo = dataPointDao.getDataPoint(xid);
            if (vo == null)
                throw new TranslatableJsonException("emport.error.missingPoint", xid);
            sourcePointId = vo.getId();
        }

        xid = jsonObject.getString("targetPointId");
        if (xid != null) {
            DataPointVO vo = dataPointDao.getDataPoint(xid);
            if (vo == null)
                throw new TranslatableJsonException("emport.error.missingPoint", xid);
            targetPointId = vo.getId();
        }

        String text = jsonObject.getString("event");
        if (text != null) {
            event = EVENT_CODES.getId(text);
            if (!EVENT_CODES.isValidId(event))
                throw new TranslatableJsonException("emport.error.link.invalid", "event", text,
                        EVENT_CODES.getCodeList());
        }
    }
View Full Code Here

    @Override
    public void jsonRead(JsonReader reader, JsonObject jsonObject) throws JsonException {
        String text = jsonObject.getString("attributeId");
        if (text == null)
            throw new TranslatableJsonException("emport.error.missing", "attributeId", ATTRIBUTE_CODES.getCodeList());
        attributeId = ATTRIBUTE_CODES.getId(text);
        if (!ATTRIBUTE_CODES.isValidId(attributeId))
            throw new TranslatableJsonException("emport.error.invalid", "attributeId", text,
                    ATTRIBUTE_CODES.getCodeList());
    }
View Full Code Here

    public void jsonRead(JsonReader reader, com.serotonin.json.type.JsonObject jsonObject) throws JsonException {
        super.jsonRead(reader, jsonObject);

        String xid = jsonObject.getString("XID");
        if (xid == null)
            throw new TranslatableJsonException("emport.error.eventType.missing.reference", "XID");
        MaintenanceEventVO me = new MaintenanceEventDao().getMaintenanceEvent(xid);
        if (me == null)
            throw new TranslatableJsonException("emport.error.eventType.invalid.reference", "XID", xid);
        maintenanceId = me.getId();
    }
View Full Code Here

            for (JsonValue jv : jsonStateList) {
                JsonObject jsonMapping = jv.toJsonObject();
                Integer state = jsonMapping.getInt("state");
                if (state == null)
                    throw new TranslatableJsonException("emport.error.missingValue", "state");

                Integer index = jsonMapping.getInt("imageIndex");
                if (index == null)
                    throw new TranslatableJsonException("emport.error.missingValue", "index");

                stateImageMap.put(state, index);
            }
        }
    }
View Full Code Here

        JsonValue jsonImageId = jsonObject.get("imageSet");
        if (jsonImageId != null) {
            String id = jsonImageId.toString();
            imageSet = Common.getImageSet(id);
            if (imageSet == null)
                throw new TranslatableJsonException("emport.error.component.unknownImageSet", id,
                        Common.getImageSetIds());
        }
    }
View Full Code Here

        JsonObject jsonChildren = jsonObject.getJsonObject("children");
        if (jsonChildren != null) {
            for (Map.Entry<String, JsonValue> jsonChild : jsonChildren.entrySet()) {
                CompoundChild child = getChild(jsonChild.getKey());
                if (child == null || !child.getViewComponent().isPointComponent())
                    throw new TranslatableJsonException("emport.error.compound.invalidChildId", jsonChild.getKey(),
                            definition().getId(), getPointComponentChildIds());
                jsonReadDataPoint(jsonChild.getValue(), (PointComponent) child.getViewComponent());
            }
        }
    }
View Full Code Here

TOP

Related Classes of com.serotonin.m2m2.i18n.TranslatableJsonException

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.