Package com.serotonin.m2m2.db.dao

Examples of com.serotonin.m2m2.db.dao.UserDao


        SerialDataSourceVO ds = (SerialDataSourceVO) Common.getUser().getEditDataSource();
        if(ds.getId() == -1) {
          pr.addContextualMessage("testString", "serial.test.needsSave");
          return pr;
        }
        DataPointDao dpd = new DataPointDao();
        List<DataPointVO> points = dpd.getDataPoints(ds.getId(), null);
        if(ds.getUseTerminator()) {
          if(msg.indexOf(ds.getMessageTerminator()) != -1) {
            msg = msg.substring(0, msg.indexOf(ds.getMessageTerminator())+1);
            Pattern p = Pattern.compile(ds.getMessageRegex());
            Matcher m = p.matcher(msg);
View Full Code Here


        return null;
    }

    private int importCsv(FileItem item) throws IOException, TranslatableException {
        CSVReader csvReader = new CSVReader(new InputStreamReader(item.getInputStream()));
        DataPointDao dataPointDao = new DataPointDao();
        PointValueDao pointValueDao = Common.databaseProxy.newPointValueDao();
        DateTimeFormatter dtf = DateTimeFormat.forPattern("yyyy/MM/dd HH:mm:ss");

        // Basic validation
        String[] nextLine = csvReader.readNext();
        if (nextLine == null)
            throw new TranslatableException(new TranslatableMessage("dataImport.import.noData"));
        if (nextLine.length < 2)
            throw new TranslatableException(new TranslatableMessage("dataImport.import.noPoints"));

        // Find the points by XID
        DataPointVO[] vos = new DataPointVO[nextLine.length - 1];

        for (int i = 1; i < nextLine.length; i++) {
            if (StringUtils.isBlank(nextLine[i]))
                throw new TranslatableException(new TranslatableMessage("dataImport.import.badXid", i));

            DataPointVO vo = dataPointDao.getDataPoint(nextLine[i]);
            if (vo == null)
                throw new TranslatableException(new TranslatableMessage("dataImport.import.xidNotFound", nextLine[i]));

            vos[i - 1] = vo;
        }
View Full Code Here

    }

    private int importCsv(FileItem item) throws IOException, TranslatableException {
        CSVReader csvReader = new CSVReader(new InputStreamReader(item.getInputStream()));
        DataPointDao dataPointDao = new DataPointDao();
        PointValueDao pointValueDao = Common.databaseProxy.newPointValueDao();
        DateTimeFormatter dtf = DateTimeFormat.forPattern("yyyy/MM/dd HH:mm:ss");

        // Basic validation
        String[] nextLine = csvReader.readNext();
        if (nextLine == null)
            throw new TranslatableException(new TranslatableMessage("dataImport.import.noData"));
        if (nextLine.length < 2)
            throw new TranslatableException(new TranslatableMessage("dataImport.import.noPoints"));

        // Find the points by XID
        DataPointVO[] vos = new DataPointVO[nextLine.length - 1];

        for (int i = 1; i < nextLine.length; i++) {
            if (StringUtils.isBlank(nextLine[i]))
                throw new TranslatableException(new TranslatableMessage("dataImport.import.badXid", i));

            DataPointVO vo = dataPointDao.getDataPoint(nextLine[i]);
            if (vo == null)
                throw new TranslatableException(new TranslatableMessage("dataImport.import.xidNotFound", nextLine[i]));

            vos[i - 1] = vo;
        }

        // Find the RTs for the points if they are enabled
        DataPointRT[] rts = new DataPointRT[vos.length];
        for (int i = 0; i < vos.length; i++)
            rts[i] = Common.runtimeManager.getDataPoint(vos[i].getId());

        // Import the data
        int count = 0;
        while ((nextLine = csvReader.readNext()) != null) {
            // The first value is always a date.
            long time = dtf.parseDateTime(nextLine[0]).getMillis();

            // The rest of the values are point samples.
            for (int i = 1; i < nextLine.length; i++) {
                DataValue value = DataValue.stringToValue(nextLine[i], vos[i - 1].getPointLocator().getDataTypeId());
                PointValueTime pvt = new PointValueTime(value, time);

                if (rts[i - 1] != null)
                    rts[i - 1].savePointValueDirectToCache(pvt, null, true, true);
                else
                    // Save directly to the database
                    pointValueDao.savePointValueAsync(vos[i - 1].getId(), pvt, null);
            }

            count++;
        }
View Full Code Here

      return ans;
    }

    //Helper for JSP Page
    public String getUsername(){
      UserDao userDao = new UserDao();
      User reportUser = userDao.getUser(this.userId);
        if(reportUser != null)
          return reportUser.getUsername();
        else
          return Common.translate("reports.validate.userDNE");
    }
View Full Code Here

        if (previousPeriodCount < 1)
            response.addContextualMessage("previousPeriodCount", "reports.validate.periodCountLessThan1");
        if (pastPeriodCount < 1)
            response.addContextualMessage("pastPeriodCount", "reports.validate.periodCountLessThan1");
       
        UserDao dao = new UserDao();
        User user = dao.getUser(userId);
        if(user == null){
            response.addContextualMessage("userId", "reports.validate.userDNE");
        }
       
        File t = new File(Common.MA_HOME + ModuleRegistry.getModule("reports").getDirectoryPath() + "/web/ftl/" + template);
View Full Code Here

    public static void queueReport(ReportVO report) {
        LOG.debug("Queuing report with id " + report.getId());

        // Verify that the user is not disabled.
        User user = new UserDao().getUser(report.getUserId());
        if (user.isDisabled())
            return;

        // User is ok. Continue...
        ReportWorkItem item = new ReportWorkItem();
View Full Code Here

        xidMap = template.getXidMapping();
        templateFile = template.getTemplate();
        includeEvents = template.getIncludeEvents();
        includeUserComments = template.isIncludeUserComments();

        UserDao userDao = new UserDao();
        User reportUser = userDao.getUser(userId);
        if(reportUser != null)
          username = reportUser.getUsername();
        else
          username = Common.translate("reports.validate.userDNE");
       
View Full Code Here

        ReportDao reportDao = new ReportDao();
        User user = Common.getUser();

        response.addData("points", getReadablePoints());
        response.addData("mailingLists", new MailingListDao().getMailingLists());
        response.addData("users", new UserDao().getUsers());
        if(user.isAdmin()) {
          response.addData("reports", reportDao.getReports());
          response.addData("instances", getReportInstances(user));
      }
        else {
View Full Code Here

      if(user.isAdmin())
        result = new ReportDao().getReportInstances();
      else
        result = new ReportDao().getReportInstances(user.getId());
        Translations translations = getTranslations();
        UserDao userDao = new UserDao();
        for (ReportInstance i : result){
            i.setTranslations(translations);
            User reportUser = userDao.getUser(i.getUserId());
            if(reportUser != null)
              i.setUsername(reportUser.getUsername());
            else
              i.setUsername(Common.translate("reports.validate.userDNE"));
           
View Full Code Here

     * This method is used before the view is displayed in order to validate: - that the given user is allowed to access
     * points that back any components - that the points that back components still have valid data types for the
     * components that render them
     */
    public void validateViewComponents(boolean makeReadOnly) {
        User owner = new UserDao().getUser(userId);
        for (ViewComponent viewComponent : viewComponents)
            viewComponent.validateDataPoint(owner, makeReadOnly);
    }
View Full Code Here

TOP

Related Classes of com.serotonin.m2m2.db.dao.UserDao

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.