Exemplo n.º 1
0
  /**
   * set a model to apply content to user interface.
   *
   * @param p a object
   */
  public void setModel(Object p) {

    sqlPredicate = ((SQLPredicate) ((TreeObject) p).getUserObject());
    treeObject = (TreeObject) p;
    textName.setText(sqlPredicate.getName() == null ? "" : sqlPredicate.getName());
    textQuery.setText(sqlPredicate.getQuery() == null ? "" : sqlPredicate.getQuery());

    // set the data sources
    DataSource ds = sqlPredicate.getDataSource() == null ? null : sqlPredicate.getDataSource();

    if (ds != null && !dataSources.contains(ds)) dataSources.add(ds);
    setDataSources(repositoryTreeView.kbplus.repository.getDataSources());
    //		displayDataSources();
    labelCurrentDS.setText(ds.toString());

    textClass.setEnabled(false);
    buttonBrowse.setEnabled(false);
    if (sqlPredicate.getTypeMapping() != null) {
      textClass.setData(sqlPredicate.getTypeMapping().getClass());
      textClass.setText(sqlPredicate.getTypeMapping().getClass().toString());
      if (sqlPredicate.getTypeMapping().getClass() == DefaultTypeMapping.class) {
        rbDefault.setSelection(true);
        rbMeta.setSelection(false);
        rbCustom.setSelection(false);
      } else {
        rbCustom.setSelection(true);
        rbDefault.setSelection(false);
        rbMeta.setSelection(false);
        textClass.setEnabled(true);
        buttonBrowse.setEnabled(true);
      }
    } else {
      textClass.setData(null);
      textClass.setText("");
      rbMeta.setSelection(true);
      rbDefault.setSelection(false);
      rbCustom.setSelection(false);
    }
  }
Exemplo n.º 2
0
  @PostConstruct
  private void myPostConstructMethod() {
    postConstructResult = "<span class=\"pass\">PASS</span>";
    try {
      dsResult =
          (myDS == null
              ? "<span class=\"fail\">FAIL</span>"
              : "<span class=\"pass\">myDS=" + myDS.toString() + "</span>");
    } catch (Exception e) {
      dsResult = "<span class=\"fail\">FAIL:</span> " + e;
    }

    envResult =
        (maxAmount == null
            ? "FAIL</span>"
            : "<span class=\"pass\">maxAmount=" + maxAmount.toString() + "</span>");

    try {
      InitialContext ic = new InitialContext();
      envLookupResult =
          "java:comp/env/com.acme.AnnotationTest/maxAmount="
              + ic.lookup("java:comp/env/com.acme.AnnotationTest/maxAmount");
    } catch (Exception e) {
      envLookupResult = "<span class=\"fail\">FAIL:</span> " + e;
    }

    envResult2 =
        (minAmount == null
            ? "<span class=\"fail\">FAIL</span>"
            : "<span class=\"pass\">minAmount=" + minAmount.toString() + "</span>");
    try {
      InitialContext ic = new InitialContext();
      envLookupResult2 = "java:comp/env/someAmount=" + ic.lookup("java:comp/env/someAmount");
    } catch (Exception e) {
      envLookupResult2 = "<span class=\"fail\">FAIL:</span> " + e;
    }
    envResult3 =
        (minAmount == null
            ? "<span class=\"fail\">FAIL</span>"
            : "<span class=\"pass\">avgAmount=" + avgAmount.toString() + "</span>");
    try {
      InitialContext ic = new InitialContext();
      envLookupResult3 =
          "java:comp/env/com.acme.AnnotationTest/avgAmount="
              + ic.lookup("java:comp/env/com.acme.AnnotationTest/avgAmount");
    } catch (Exception e) {
      envLookupResult3 = "<span class=\"fail\">FAIL:</span> " + e;
    }

    try {
      InitialContext ic = new InitialContext();
      dsLookupResult =
          "java:comp/env/com.acme.AnnotationTest/myDatasource="
              + ic.lookup("java:comp/env/com.acme.AnnotationTest/myDatasource");
    } catch (Exception e) {
      dsLookupResult = "<span class=\"fail\">FAIL:</span> " + e;
    }

    txResult =
        (myUserTransaction == null
            ? "<span class=\"fail\">FAIL</span>"
            : "<span class=\"pass\">myUserTransaction=" + myUserTransaction + "</span>");
    try {
      InitialContext ic = new InitialContext();
      txLookupResult =
          "java:comp/env/com.acme.AnnotationTest/myUserTransaction="
              + ic.lookup("java:comp/env/com.acme.AnnotationTest/myUserTransaction");
    } catch (Exception e) {
      txLookupResult = "<span class=\"fail\">FAIL:</span> " + e;
    }
  }
Exemplo n.º 3
0
 public void setDatasource(DataSource _ds) {
   this._ds = _ds;
   System.out.println("Set Data Source in Model" + _ds.toString());
 }
Exemplo n.º 4
0
 static String toString(DataSource ds) {
   if (ds instanceof AbstractPoolBackedDataSource)
     return ((AbstractPoolBackedDataSource) ds).toString(true);
   else return ds.toString();
 }