예제 #1
0
  @Override
  protected void init() {
    setName(WString.tr("form.query.custom.nadir.name").getValue());
    setDescription(WString.tr("form.query.custom.nadir.description").getValue());

    pDataset = new DatasetParameter(this, "Dataset", true);
    pDate = new DateParameter(this, "Date", true);
    pTestType =
        new TestTypeParameter(
            "Test type",
            true,
            new TestTypeComboBox(InteractionState.Adding, this) {
              public void addItem(DataComboMessage<TestType> item) {
                if (item.getDataValue() != null) {
                  ValueTypes vt = ValueTypes.getValueType(item.getDataValue().getValueType());
                  if (!(vt == ValueTypes.LIMITED_NUMBER || vt == ValueTypes.NUMBER)) return;
                }
                super.addItem(item);
              }
            });

    getParameters().add(pDataset);
    getParameters().add(pTestType);
    getParameters().add(pDate);
  }
예제 #2
0
 private void handleRedirectPath(String internalPath) {
   if (internalPath.equals(this.service_.getRedirectInternalPath())) {
     WApplication app = WApplication.getInstance();
     WEnvironment env = app.getEnvironment();
     if (!env.hasAjax()) {
       String stateE = env.getParameter("state");
       if (!(stateE != null) || !stateE.equals(this.oAuthState_)) {
         this.setError(WString.tr("Wt.Auth.OAuthService.invalid-state"));
       } else {
         String errorE = env.getParameter("error");
         if (errorE != null) {
           this.setError(WString.tr("Wt.Auth.OAuthService." + errorE));
         } else {
           String codeE = env.getParameter("code");
           if (!(codeE != null)) {
             this.setError(WString.tr("Wt.Auth.OAuthService.missing-code"));
           } else {
             this.requestToken(codeE);
           }
         }
       }
       this.onOAuthDone();
     }
   }
 }
예제 #3
0
 private OAuthAccessToken parseUrlEncodedToken(HttpMessage response) {
   Map<String, String[]> params = new HashMap<String, String[]>();
   AuthUtils.parseFormUrlEncoded(response, params);
   if (response.getStatus() == 200) {
     String accessTokenE = AuthUtils.getParamValue(params, "access_token");
     if (accessTokenE != null) {
       String accessToken = accessTokenE;
       WDate expires = null;
       String expiresE = AuthUtils.getParamValue(params, "expires");
       if (expiresE != null) {
         expires = new WDate(new Date()).addSeconds(Integer.parseInt(expiresE));
       }
       return new OAuthAccessToken(accessToken, expires, "");
     } else {
       throw new OAuthProcess.TokenError(WString.tr("Wt.Auth.OAuthService.badresponse"));
     }
   } else {
     String errorE = AuthUtils.getParamValue(params, "error");
     if (errorE != null) {
       throw new OAuthProcess.TokenError(WString.tr("Wt.Auth.OAuthService." + errorE));
     } else {
       throw new OAuthProcess.TokenError(WString.tr("Wt.Auth.OAuthService.badresponse"));
     }
   }
 }
예제 #4
0
 /**
  * Parses the response for a token request.
  *
  * <p>Throws a {@link TokenError} when the response indicates an error, or when the response could
  * not be properly parsed.
  *
  * <p>Some OAuth implementations may uses a non-standard encoding of the token.
  */
 protected OAuthAccessToken parseTokenResponse(HttpMessage response) {
   if (response.getStatus() == 200 || response.getStatus() == 400) {
     String type = response.getHeader("Content-Type");
     if (type != null) {
       if (type.startsWith("text/plain; charset=UTF-8")) {
         return this.parseUrlEncodedToken(response);
       } else {
         if (type.startsWith("application/json")) {
           return this.parseJsonToken(response);
         } else {
           throw new OAuthProcess.TokenError(WString.tr("Wt.Auth.OAuthService.badresponse"));
         }
       }
     } else {
       throw new OAuthProcess.TokenError(WString.tr("Wt.Auth.OAuthService.badresponse"));
     }
   } else {
     throw new OAuthProcess.TokenError(WString.tr("Wt.Auth.OAuthService.badresponse"));
   }
 }
예제 #5
0
 private OAuthAccessToken parseJsonToken(HttpMessage response) {
   com.google.gson.JsonObject root = new com.google.gson.JsonObject();
   com.google.gson.JsonParseException pe = null;
   try {
     root =
         (com.google.gson.JsonObject) new com.google.gson.JsonParser().parse(response.getBody());
   } catch (com.google.gson.JsonParseException error) {
     pe = error;
   }
   boolean ok = root != null;
   if (!ok) {
     logger.error(
         new StringWriter().append("parseJsonToken(): ").append(pe.toString()).toString());
     throw new OAuthProcess.TokenError(WString.tr("Wt.Auth.OAuthService.badjson"));
   } else {
     if (response.getStatus() == 200) {
       try {
         String accessToken = root.get("access_token").getAsString();
         int secs = JsonUtils.orIfNullInt(root.get("expires_in"), -1);
         WDate expires = null;
         if (secs > 0) {
           expires = new WDate(new Date()).addSeconds(secs);
         }
         String refreshToken = JsonUtils.orIfNullString(root.get("refreshToken"), "");
         return new OAuthAccessToken(accessToken, expires, refreshToken);
       } catch (RuntimeException e) {
         logger.error(
             new StringWriter().append("token response error: ").append(e.toString()).toString());
         throw new OAuthProcess.TokenError(WString.tr("Wt.Auth.OAuthService.badresponse"));
       }
     } else {
       throw new OAuthProcess.TokenError(
           WString.tr(
               "Wt.Auth.OAuthService."
                   + JsonUtils.orIfNullString(root.get("error"), "missing error")));
     }
   }
 }
예제 #6
0
 public void newValue(
     final WDataSeries series,
     double x,
     double y,
     double stackY,
     int xRow,
     int xColumn,
     int yRow,
     int yColumn) {
   if (!Double.isNaN(x) && !Double.isNaN(y)) {
     WPointF p =
         this.chart_.map(
             x, y, series.getAxis(), this.getCurrentXSegment(), this.getCurrentYSegment());
     if (!this.marker_.isEmpty()) {
       WPen pen = series.getMarkerPen().clone();
       SeriesIterator.setPenColor(
           pen, series, xRow, xColumn, yRow, yColumn, ItemDataRole.MarkerPenColorRole);
       if (this.chart_.isSeriesSelectionEnabled()
           && this.chart_.getSelectedSeries() != null
           && this.chart_.getSelectedSeries() != series) {
         pen.setColor(WCartesianChart.lightenColor(pen.getColor()));
       }
       WBrush brush = series.getMarkerBrush().clone();
       SeriesIterator.setBrushColor(
           brush, series, xRow, xColumn, yRow, yColumn, ItemDataRole.MarkerBrushColorRole);
       double scale =
           this.calculateMarkerScale(series, xRow, xColumn, yRow, yColumn, series.getMarkerSize());
       if (this.chart_.isSeriesSelectionEnabled()
           && this.chart_.getSelectedSeries() != null
           && this.chart_.getSelectedSeries() != series) {
         brush.setColor(WCartesianChart.lightenColor(brush.getColor()));
       }
       if (!(this.series_ != null)
           || !brush.equals(this.currentBrush_)
           || !pen.equals(this.currentPen_)
           || scale != this.currentScale_) {
         if (this.series_ != null) {
           this.finishPathFragment(this.series_);
         }
         this.series_ = series;
         this.currentBrush_ = brush;
         this.currentPen_ = pen;
         this.currentScale_ = scale;
       }
       this.pathFragment_.moveTo(this.hv(p));
     }
     if (series.getType() != SeriesType.BarSeries) {
       WString toolTip = series.getModel().getToolTip(yRow, yColumn);
       if (!(toolTip.length() == 0)) {
         if (!(!EnumUtils.mask(
                     series.getModel().flags(yRow, yColumn), ItemFlag.ItemHasDeferredTooltip)
                 .isEmpty()
             || !EnumUtils.mask(series.getModel().flags(yRow, yColumn), ItemFlag.ItemIsXHTMLText)
                 .isEmpty())) {
           WTransform t = this.painter_.getWorldTransform();
           p = t.map(this.hv(p));
           WCircleArea circleArea = new WCircleArea();
           circleArea.setCenter(new WPointF(p.getX(), p.getY()));
           circleArea.setRadius(5);
           circleArea.setToolTip(toolTip);
           this.chart_.addDataPointArea(series, xRow, xColumn, circleArea);
         } else {
           this.chart_.hasDeferredToolTips_ = true;
         }
       }
     }
   }
 }
예제 #7
0
public class IDatasetDataTable extends DefaultDataTable<Dataset> {
  public IDatasetDataTable(SelectForm<Dataset> form) {
    super(form);
  }

  private static WString[] _colNames = {
    WString.tr("dataTable.dataset.colName.description"),
    WString.tr("dataTable.dataset.colName.creationDate"),
    WString.tr("dataTable.dataset.colName.closedDate"),
    WString.tr("dataTable.dataset.colName.revision")
  };
  private static String[] filterVarNames_ = {
    "dataset.description", "dataset.creationDate", "dataset.closedDate", "dataset.revision"
  };
  private IFilter[] filters_ = new IFilter[4];

  private static boolean[] sortable_ = {true, true, true, true};

  private static int[] colWidths = {25, 25, 25, 25};

  public CharSequence[] getColNames() {
    return _colNames;
  }

  public List<Dataset> getDataBlock(
      Transaction t, int startIndex, int amountOfRows, int sortIndex, boolean isAscending) {
    return t.getDatasets(
        startIndex,
        amountOfRows,
        filterVarNames_[sortIndex],
        isAscending,
        HibernateStringUtils.filterConstraintsQuery(this));
  }

  public long getDataSetSize(Transaction t) {
    return t.getDatasetCount(HibernateStringUtils.filterConstraintsQuery(this));
  }

  public String[] getFieldNames() {
    return filterVarNames_;
  }

  public IFilter[] getFilters() {
    return filters_;
  }

  public String[] getRowData(Dataset dataset) {
    String[] row = new String[4];

    row[0] = dataset.getDescription();
    row[1] = DateUtils.format(dataset.getCreationDate());
    row[2] = DateUtils.format(dataset.getClosedDate());
    row[3] = String.valueOf(dataset.getRevision());

    return row;
  }

  public void init(Transaction t) {
    filters_[0] = new StringFilter();
    filters_[1] = new DateFilter(RegaDBSettings.getInstance().getDateFormat());
    filters_[2] = new DateFilter(RegaDBSettings.getInstance().getDateFormat());
    filters_[3] = new StringFilter();
  }

  public boolean[] sortableFields() {
    return sortable_;
  }

  public int[] getColumnWidths() {
    return colWidths;
  }

  public String[] getRowTooltips(Dataset type) {
    return null;
  }
}
예제 #8
0
 public NadirQuery() {
   super(WString.tr("form.query.custom.nadir.name"));
 }
예제 #9
0
 /**
  * Sets the error.
  *
  * <p>This should be used in {@link OAuthProcess#getIdentity(OAuthAccessToken token)
  * getIdentity()} implementations to set the error, before emitting {@link
  * OAuthProcess#authenticated() authenticated()} with an invalid {@link Identity}.
  */
 protected void setError(CharSequence error) {
   this.error_ = WString.toWString(error);
 }
예제 #10
0
 /** Constructor. */
 public TokenError(CharSequence error) {
   super();
   this.error_ = WString.toWString(error);
 }