Java 类weka.core.converters.DatabaseLoader 实例源码

项目:repo.kmeanspp.silhouette_score    文件:Loader.java   
protected void newFileSelected() throws Exception {
  if (!(m_Loader instanceof DatabaseLoader)) {
    newStructure(true);
    /*
     * // try to load structure (if possible) and notify any listeners
     * 
     * // Set environment variables if (m_Loader instanceof EnvironmentHandler
     * && m_env != null) { try {
     * ((EnvironmentHandler)m_Loader).setEnvironment(m_env); }catch (Exception
     * ex) { } } m_dataFormat = m_Loader.getStructure(); //
     * System.err.println(m_dataFormat); System.out.println(
     * "[Loader] Notifying listeners of instance structure avail.");
     * notifyStructureAvailable(m_dataFormat);
     */
  }
}
项目:repo.kmeanspp.silhouette_score    文件:Loader.java   
/**
 * Add a listener
 * 
 * @param dsl a <code>DataSourceListener</code> value
 */
@Override
public synchronized void addDataSourceListener(DataSourceListener dsl) {
  super.addDataSourceListener(dsl);
  m_dataSetEventTargets++;
  // pass on any current instance format
  try {
    if ((m_Loader instanceof DatabaseLoader && m_dbSet && m_dataFormat == null)
      || (!(m_Loader instanceof DatabaseLoader) && m_dataFormat == null)) {
      m_dataFormat = m_Loader.getStructure();
      m_dbSet = false;
    }
  } catch (Exception ex) {
  }
  notifyStructureAvailable(m_dataFormat);
}
项目:repo.kmeanspp.silhouette_score    文件:Loader.java   
/**
 * Add an instance listener
 * 
 * @param dsl a <code>InstanceListener</code> value
 */
@Override
public synchronized void addInstanceListener(InstanceListener dsl) {
  super.addInstanceListener(dsl);
  m_instanceEventTargets++;
  try {
    if ((m_Loader instanceof DatabaseLoader && m_dbSet && m_dataFormat == null)
      || (!(m_Loader instanceof DatabaseLoader) && m_dataFormat == null)) {
      m_dataFormat = m_Loader.getStructure();
      m_dbSet = false;
    }
  } catch (Exception ex) {
  }
  // pass on any current instance format
  m_ie.m_formatNotificationOnly = true;
  notifyStructureAvailable(m_dataFormat);
}
项目:autoweka    文件:Loader.java   
protected void newFileSelected() throws Exception {
    if(! (m_Loader instanceof DatabaseLoader)) {
      newStructure();
/*      // try to load structure (if possible) and notify any listeners

      // Set environment variables
      if (m_Loader instanceof EnvironmentHandler && m_env != null) {
        try {
          ((EnvironmentHandler)m_Loader).setEnvironment(m_env);
        }catch (Exception ex) {
        }
      }
      m_dataFormat = m_Loader.getStructure();
      //      System.err.println(m_dataFormat);
      System.out.println("[Loader] Notifying listeners of instance structure avail.");
      notifyStructureAvailable(m_dataFormat); */
    }
  }
项目:umple    文件:Loader.java   
protected void newFileSelected() throws Exception {
  if (!(m_Loader instanceof DatabaseLoader)) {
    newStructure(true);
    /*
     * // try to load structure (if possible) and notify any listeners
     * 
     * // Set environment variables if (m_Loader instanceof EnvironmentHandler
     * && m_env != null) { try {
     * ((EnvironmentHandler)m_Loader).setEnvironment(m_env); }catch (Exception
     * ex) { } } m_dataFormat = m_Loader.getStructure(); //
     * System.err.println(m_dataFormat); System.out.println(
     * "[Loader] Notifying listeners of instance structure avail.");
     * notifyStructureAvailable(m_dataFormat);
     */
  }
}
项目:umple    文件:Loader.java   
/**
 * Add a listener
 * 
 * @param dsl a <code>DataSourceListener</code> value
 */
@Override
public synchronized void addDataSourceListener(DataSourceListener dsl) {
  super.addDataSourceListener(dsl);
  m_dataSetEventTargets++;
  // pass on any current instance format
  try {
    if ((m_Loader instanceof DatabaseLoader && m_dbSet && m_dataFormat == null)
      || (!(m_Loader instanceof DatabaseLoader) && m_dataFormat == null)) {
      m_dataFormat = m_Loader.getStructure();
      m_dbSet = false;
    }
  } catch (Exception ex) {
  }
  notifyStructureAvailable(m_dataFormat);
}
项目:umple    文件:Loader.java   
/**
 * Add an instance listener
 * 
 * @param dsl a <code>InstanceListener</code> value
 */
@Override
public synchronized void addInstanceListener(InstanceListener dsl) {
  super.addInstanceListener(dsl);
  m_instanceEventTargets++;
  try {
    if ((m_Loader instanceof DatabaseLoader && m_dbSet && m_dataFormat == null)
      || (!(m_Loader instanceof DatabaseLoader) && m_dataFormat == null)) {
      m_dataFormat = m_Loader.getStructure();
      m_dbSet = false;
    }
  } catch (Exception ex) {
  }
  // pass on any current instance format
  m_ie.m_formatNotificationOnly = true;
  notifyStructureAvailable(m_dataFormat);
}
项目:jbossBA    文件:LoaderCustomizer.java   
private boolean resetAndUpdateDatabaseLoaderIfChanged() {
  DatabaseLoader dbl = (DatabaseLoader)m_dsLoader.getLoader();
  String url = dbl.getUrl();
  String user = dbl.getUser();
  String password = dbl.getPassword();
  String query = dbl.getQuery();
  String keys = dbl.getKeys();

  boolean update = (!url.equals(m_dbaseURLText.getText()) || 
      !user.equals(m_userNameText.getText()) ||
      !password.equals(m_passwordText.getText()) ||
      !query.equalsIgnoreCase(m_queryText.getText())||
      !keys.equals(m_keyText.getText()));

  if (update) {
    dbl.resetStructure();  
    dbl.setUrl(m_dbaseURLText.getText());
    dbl.setUser(m_userNameText.getText());
    dbl.setPassword(new String(m_passwordText.getPassword()));
    dbl.setQuery(m_queryText.getText());
    dbl.setKeys(m_keyText.getText());
  }

  return update;
}
项目:jbossBA    文件:WekaApacheEngine.java   
public Map<String, VariableType> getNomNumMap(DataSource dataSource, String table) throws Exception {
    Map<String, VariableType> nomNumMap = new HashMap<String, VariableType>();

    DatabaseLoader databaseLoader = new DatabaseLoader();
    databaseLoader.setDataSource(dataSource);
    databaseLoader.setQuery("select * from " + table + " limit 20, 20");
    Instances wekaData = databaseLoader.getDataSet();

    List<Attribute> attributes = Collections.list(wekaData.enumerateAttributes());

    for (Attribute attribute : attributes) {
        if (attribute.isNumeric() || attribute.isDate()) {
            nomNumMap.put(attribute.name(), VariableType.NUMERIC);
        } else if (attribute.isNominal() || attribute.isString()) {
            nomNumMap.put(attribute.name(), VariableType.CATEGORICAL);
        } else {
            new RuntimeException(this.getClass().getName() + "impl me").printStackTrace();
        }
    }


    return nomNumMap;
}
项目:repo.kmeanspp.silhouette_score    文件:LoaderCustomizer.java   
private boolean resetAndUpdateDatabaseLoaderIfChanged() {
  DatabaseLoader dbl = (DatabaseLoader) m_dsLoader.getLoader();
  String url = dbl.getUrl();
  String user = dbl.getUser();
  String password = dbl.getPassword();
  String query = dbl.getQuery();
  String keys = dbl.getKeys();
  File propsFile = dbl.getCustomPropsFile();

  boolean update = (!url.equals(m_dbaseURLText.getText())
    || !user.equals(m_userNameText.getText())
    || !Arrays.equals(password.toCharArray(), m_passwordText.getPassword())
    || !query.equalsIgnoreCase(m_queryText.getText()) || !keys
    .equals(m_keyText.getText()));

  if (propsFile != null && m_dbProps.getText().length() > 0) {
    update = (update || !propsFile.toString().equals(m_dbProps.getText()));
  } else {
    update = (update || m_dbProps.getText().length() > 0);
  }

  if (update) {
    dbl.resetStructure();
    dbl.setUrl(m_dbaseURLText.getText());
    dbl.setUser(m_userNameText.getText());
    dbl.setPassword(new String(m_passwordText.getPassword()));
    dbl.setQuery(m_queryText.getText());
    dbl.setKeys(m_keyText.getText());
    if (m_dbProps.getText() != null && m_dbProps.getText().length() > 0) {
      dbl.setCustomPropsFile(new File(m_dbProps.getText()));
    }
  }

  return update;
}
项目:autoweka    文件:Loader.java   
/**
 * Add a listener
 *
 * @param dsl a <code>DataSourceListener</code> value
 */
public synchronized void addDataSourceListener(DataSourceListener dsl) {
  super.addDataSourceListener(dsl);
  m_dataSetEventTargets ++;
  // pass on any current instance format
  try{
    if((m_Loader instanceof DatabaseLoader && m_dbSet && m_dataFormat == null) || 
       (!(m_Loader instanceof DatabaseLoader) && m_dataFormat == null)) {
      m_dataFormat = m_Loader.getStructure();
      m_dbSet = false;
    }
  }catch(Exception ex){
  }
  notifyStructureAvailable(m_dataFormat);
}
项目:autoweka    文件:Loader.java   
/**
 * Add an instance listener
 *
 * @param dsl a <code>InstanceListener</code> value
 */
public synchronized void addInstanceListener(InstanceListener dsl) {
  super.addInstanceListener(dsl);
  m_instanceEventTargets ++;
  try{
    if((m_Loader instanceof DatabaseLoader && m_dbSet && m_dataFormat == null) || 
       (!(m_Loader instanceof DatabaseLoader) && m_dataFormat == null)) {
      m_dataFormat = m_Loader.getStructure();
      m_dbSet = false;
    }
  }catch(Exception ex){
  }
  // pass on any current instance format      
  notifyStructureAvailable(m_dataFormat);
}
项目:autoweka    文件:LoaderCustomizer.java   
private boolean resetAndUpdateDatabaseLoaderIfChanged() {
  DatabaseLoader dbl = (DatabaseLoader)m_dsLoader.getLoader();
  String url = dbl.getUrl();
  String user = dbl.getUser();
  String password = dbl.getPassword();
  String query = dbl.getQuery();
  String keys = dbl.getKeys();
  File propsFile = dbl.getCustomPropsFile();

  boolean update = (!url.equals(m_dbaseURLText.getText()) || 
      !user.equals(m_userNameText.getText()) ||
      !password.equals(m_passwordText.getText()) ||
      !query.equalsIgnoreCase(m_queryText.getText())||
      !keys.equals(m_keyText.getText()));

  if (propsFile != null && m_dbProps.getText().length() > 0) {
     update = (update || !propsFile.toString().equals(m_dbProps.getText()));        
  } else {
    update = (update || m_dbProps.getText().length() > 0);
  }

  if (update) {
    dbl.resetStructure();  
    dbl.setUrl(m_dbaseURLText.getText());
    dbl.setUser(m_userNameText.getText());
    dbl.setPassword(new String(m_passwordText.getPassword()));
    dbl.setQuery(m_queryText.getText());
    dbl.setKeys(m_keyText.getText());
    if (m_dbProps.getText() != null && m_dbProps.getText().length() > 0) {
      dbl.setCustomPropsFile(new File(m_dbProps.getText()));
    }
  }

  return update;
}
项目:umple    文件:LoaderCustomizer.java   
private boolean resetAndUpdateDatabaseLoaderIfChanged() {
  DatabaseLoader dbl = (DatabaseLoader) m_dsLoader.getLoader();
  String url = dbl.getUrl();
  String user = dbl.getUser();
  String password = dbl.getPassword();
  String query = dbl.getQuery();
  String keys = dbl.getKeys();
  File propsFile = dbl.getCustomPropsFile();

  boolean update = (!url.equals(m_dbaseURLText.getText())
    || !user.equals(m_userNameText.getText())
    || !Arrays.equals(password.toCharArray(), m_passwordText.getPassword())
    || !query.equalsIgnoreCase(m_queryText.getText()) || !keys
    .equals(m_keyText.getText()));

  if (propsFile != null && m_dbProps.getText().length() > 0) {
    update = (update || !propsFile.toString().equals(m_dbProps.getText()));
  } else {
    update = (update || m_dbProps.getText().length() > 0);
  }

  if (update) {
    dbl.resetStructure();
    dbl.setUrl(m_dbaseURLText.getText());
    dbl.setUser(m_userNameText.getText());
    dbl.setPassword(new String(m_passwordText.getPassword()));
    dbl.setQuery(m_queryText.getText());
    dbl.setKeys(m_keyText.getText());
    if (m_dbProps.getText() != null && m_dbProps.getText().length() > 0) {
      dbl.setCustomPropsFile(new File(m_dbProps.getText()));
    }
  }

  return update;
}
项目:jbossBA    文件:Loader.java   
/**
 * Add a listener
 *
 * @param dsl a <code>DataSourceListener</code> value
 */
public synchronized void addDataSourceListener(DataSourceListener dsl) {
  super.addDataSourceListener(dsl);
  m_dataSetEventTargets ++;
  // pass on any current instance format
  try{
    if((m_Loader instanceof DatabaseLoader && m_dbSet && m_dataFormat == null) || 
       (!(m_Loader instanceof DatabaseLoader) && m_dataFormat == null)) {
      m_dataFormat = m_Loader.getStructure();
      m_dbSet = false;
    }
  }catch(Exception ex){
  }
  notifyStructureAvailable(m_dataFormat);
}
项目:jbossBA    文件:Loader.java   
/**
 * Add an instance listener
 *
 * @param dsl a <code>InstanceListener</code> value
 */
public synchronized void addInstanceListener(InstanceListener dsl) {
  super.addInstanceListener(dsl);
  m_instanceEventTargets ++;
  try{
    if((m_Loader instanceof DatabaseLoader && m_dbSet && m_dataFormat == null) || 
       (!(m_Loader instanceof DatabaseLoader) && m_dataFormat == null)) {
      m_dataFormat = m_Loader.getStructure();
      m_dbSet = false;
    }
  }catch(Exception ex){
  }
  // pass on any current instance format      
  notifyStructureAvailable(m_dataFormat);
}
项目:repo.kmeanspp.silhouette_score    文件:SQLViewerPerspective.java   
protected void newFlow() {
  m_newFlowBut.setEnabled(false);

  String user = m_viewer.getUser();
  String password = m_viewer.getPassword();
  String uRL = m_viewer.getURL();
  String query = m_viewer.getQuery();

  if (query == null) {
    query = "";
  }

  try {
    DatabaseLoader dbl = new DatabaseLoader();
    dbl.setUser(user);
    dbl.setPassword(password);
    dbl.setUrl(uRL);
    dbl.setQuery(query);

    BeanContextSupport bc = new BeanContextSupport();
    bc.setDesignTime(true);

    Loader loaderComp = new Loader();
    bc.add(loaderComp);
    loaderComp.setLoader(dbl);

    KnowledgeFlowApp singleton = KnowledgeFlowApp.getSingleton();
    m_mainPerspective.addTab("DBSource");

    // The process of creating a BeanInstance integrates will result
    // in it integrating itself into the flow in the specified tab
    new BeanInstance(m_mainPerspective.getBeanLayout(m_mainPerspective
      .getNumTabs() - 1), loaderComp, 50, 50,
      m_mainPerspective.getNumTabs()
      - 1);

    // Vector<Object> beans = BeanInstance.getBeanInstances(m_mainPerspective
    // .getNumTabs() - 1);
    // Vector<BeanConnection> connections = BeanConnection
    // .getConnections(m_mainPerspective.getNumTabs() - 1);
    // singleton.integrateFlow(beans, connections, true, false);
    singleton.setActivePerspective(0); // switch back to the main perspective

    m_newFlowBut.setEnabled(true);

  } catch (Exception ex) {
    ex.printStackTrace();
  }
}
项目:autoweka    文件:SQLViewerPerspective.java   
protected void newFlow() {
  m_newFlowBut.setEnabled(false);

  String user = m_viewer.getUser();
  String password = m_viewer.getPassword();
  String uRL = m_viewer.getURL();
  String query = m_viewer.getQuery();

  if (query == null) {
    query = "";
  }

  try {
    DatabaseLoader dbl = new DatabaseLoader();
    dbl.setUser(user);
    dbl.setPassword(password);
    dbl.setUrl(uRL);
    dbl.setQuery(query);

    BeanContextSupport bc = new BeanContextSupport();
    bc.setDesignTime(true);

    Loader loaderComp = new Loader();
    bc.add(loaderComp);
    loaderComp.setLoader(dbl);

    KnowledgeFlowApp singleton = KnowledgeFlowApp.getSingleton();      
    m_mainPerspective.addTab("DBSource");
    BeanInstance beanI = 
      new BeanInstance(m_mainPerspective.getBeanLayout(m_mainPerspective.getNumTabs() - 1),
          loaderComp, 50, 50, m_mainPerspective.getNumTabs() - 1);
    Vector beans = BeanInstance.getBeanInstances(m_mainPerspective.getNumTabs() - 1);
    Vector connections = BeanConnection.getConnections(m_mainPerspective.getNumTabs() - 1);
    singleton.integrateFlow(beans, connections, true, false);
    singleton.setActivePerspective(0); // switch back to the main perspective                  

    m_newFlowBut.setEnabled(true);

  } catch (Exception ex) {
    ex.printStackTrace();
  }
}
项目:umple    文件:SQLViewerPerspective.java   
protected void newFlow() {
  m_newFlowBut.setEnabled(false);

  String user = m_viewer.getUser();
  String password = m_viewer.getPassword();
  String uRL = m_viewer.getURL();
  String query = m_viewer.getQuery();

  if (query == null) {
    query = "";
  }

  try {
    DatabaseLoader dbl = new DatabaseLoader();
    dbl.setUser(user);
    dbl.setPassword(password);
    dbl.setUrl(uRL);
    dbl.setQuery(query);

    BeanContextSupport bc = new BeanContextSupport();
    bc.setDesignTime(true);

    Loader loaderComp = new Loader();
    bc.add(loaderComp);
    loaderComp.setLoader(dbl);

    KnowledgeFlowApp singleton = KnowledgeFlowApp.getSingleton();
    m_mainPerspective.addTab("DBSource");
    /*
     * BeanInstance beanI = new
     * BeanInstance(m_mainPerspective.getBeanLayout(m_mainPerspective
     * .getNumTabs() - 1), loaderComp, 50, 50, m_mainPerspective.getNumTabs()
     * - 1);
     */
    Vector<Object> beans = BeanInstance.getBeanInstances(m_mainPerspective
      .getNumTabs() - 1);
    Vector<BeanConnection> connections = BeanConnection
      .getConnections(m_mainPerspective.getNumTabs() - 1);
    singleton.integrateFlow(beans, connections, true, false);
    singleton.setActivePerspective(0); // switch back to the main perspective

    m_newFlowBut.setEnabled(true);

  } catch (Exception ex) {
    ex.printStackTrace();
  }
}
项目:jbossBA    文件:Loader.java   
protected void newFileSelected() throws Exception {
  if(! (m_Loader instanceof DatabaseLoader)) {
    newStructure();
  }
}