Package com.sonyericsson.hudson.plugins.metadata.model

Examples of com.sonyericsson.hudson.plugins.metadata.model.MetadataChecks


        this.defaultValue = defaultValue;
    }

    @Override
    public NumberMetadataValue createValue(Object o) throws Descriptor.FormException {
        MetadataChecks checks = new MetadataChecks();
        long value;
        if (o instanceof String) {
            FormValidation formValidation = checks.doCheckNumberValue((String)o);
            if (!formValidation.equals(FormValidation.ok())) {
                throw new Descriptor.FormException(formValidation.getMessage(), "");
            }
            value = Long.parseLong((String)o);
        } else {
View Full Code Here


    @Override
    public AbstractMetadataValue createValue(Object o) throws Descriptor.FormException {
        boolean detailsCheck = false;
        DateMetadataValue dateMetadataValue;
        Calendar cal = Calendar.getInstance();
        MetadataChecks checks = new MetadataChecks();

        if (o instanceof JSONObject) {
            String day = "";
            String month = "";
            String year = "";
            JSONObject jsonObject = (JSONObject)o;
            if (jsonObject.has("day")) {
                day = jsonObject.getString("day");
            }
            if (jsonObject.has("month")) {
                month = jsonObject.getString("month");
            }
            if (jsonObject.has("year")) {
                year = jsonObject.getString("year");
            }
            FormValidation dateValidation = checks.doCheckDateValue(year, month, day);
            if (!dateValidation.equals(FormValidation.ok())) {
                throw new Descriptor.FormException("Wrong date format " + dateValidation.getMessage(), "");
            }
            cal.set(Calendar.DAY_OF_MONTH, Integer.parseInt(day));
            cal.set(Calendar.MONTH, Integer.parseInt(month) - DEFAULT_MONTH_ADJUSTMENT);
            cal.set(Calendar.YEAR, Integer.parseInt(year));


            if (jsonObject.has("details")) {
                String hour = "";
                String minute = "";
                String second = "";
                detailsCheck = true;
                JSONObject details = jsonObject.getJSONObject("details");
                if (details.has("hour")) {
                    hour = details.getString("hour");
                }
                if (details.has("minute")) {
                    minute = details.getString("minute");
                }
                if (details.has("second")) {
                    second = details.getString("second");
                }
                FormValidation timeValidation = checks.doCheckTimeValue(hour, minute, second);
                if (!timeValidation.equals(FormValidation.ok())) {
                    throw new Descriptor.FormException("Wrong time format: " + timeValidation.getMessage(), "");
                }
                cal.set(Calendar.HOUR_OF_DAY, Integer.parseInt(hour));
                cal.set(Calendar.MINUTE, Integer.parseInt(minute));
View Full Code Here

TOP

Related Classes of com.sonyericsson.hudson.plugins.metadata.model.MetadataChecks

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.