Examples of IEvolizerSession


Examples of org.evolizer.core.hibernate.session.api.IEvolizerSession

  @Test
  public void testSaveObject() {
    try {
      fSessionHandler.createSchema(fDBUrl, fDBDialect, fDBDriverName, fDBUser, fDBPasswd);
      IEvolizerSession s = fSessionHandler.getCurrentSession(fDBUrl);
     
   
      DummyBusinessEntity entity = new DummyBusinessEntity();
      entity.setAString("This is a test");
   
      s.startTransaction();
      s.saveObject(entity);
      s.endTransaction();
   
      s.close();
   
      fSessionHandler.dropSchema(fDBUrl, fDBDialect, fDBDriverName, fDBUser, fDBPasswd);
   
    } catch (EvolizerException e) {
      fail(e.getMessage());
View Full Code Here

Examples of org.evolizer.core.hibernate.session.api.IEvolizerSession

  @Test
  public void testQuery() {
    try {
      fSessionHandler.createSchema(fDBUrl, fDBDialect, fDBDriverName, fDBUser, fDBPasswd);
      IEvolizerSession s = fSessionHandler.getCurrentSession(fDBUrl);
   
      DummyBusinessEntity entity = new DummyBusinessEntity();
      entity.setAString("This is also a test");
   
      s.startTransaction();
      s.saveObject(entity);
      s.endTransaction();
   

      List<DummyBusinessEntity> lgList = (List<DummyBusinessEntity>) s.query("from " + DummyBusinessEntity.class.getName(), DummyBusinessEntity.class);
   
      assertNotNull(lgList);
      DummyBusinessEntity savedEntity = lgList.get(0);
      assertNotNull(savedEntity);
      assertEquals(new Long(1), savedEntity.getId());
View Full Code Here

Examples of org.evolizer.core.hibernate.session.api.IEvolizerSession

     * @return the current Hibernate session.
     * @throws EvolizerException
     *             if the {@link IEvolizerSession} could not been initialized/obtained
     */
    public IEvolizerSession getCurrentSession(String dbUrl) throws EvolizerException {
        IEvolizerSession session = null;

        try {
            if (fSessionMap.containsKey(dbUrl) && fSessionMap.get(dbUrl).isOpen()) {
                session = fSessionMap.get(dbUrl);
            } else {
View Full Code Here

Examples of org.evolizer.core.hibernate.session.api.IEvolizerSession

     * @throws EvolizerException
     *             if the {@link IEvolizerSession} could not been initialized/obtained
     * @see getCurrentSession(Properties)
     */
    public IEvolizerSession getCurrentSession(IProject project) throws EvolizerException {
        IEvolizerSession session = null;

        try {
            String dbHost = project.getPersistentProperty(EvolizerPreferences.DB_HOST);
            String dbName = project.getPersistentProperty(EvolizerPreferences.DB_NAME);
            String dbUrl = dbHost + "/" + dbName;
View Full Code Here

Examples of org.evolizer.core.hibernate.session.api.IEvolizerSession

     * @param properties    The connection properties.
     * @return  The opened session.
     * @throws EvolizerException
     */
    public IEvolizerSession getCurrentSession(Properties properties) throws EvolizerException {
        IEvolizerSession session = null;

        if (properties.getProperty("hibernate.connection.url") != null) {
            String dbUrl = properties.getProperty("hibernate.connection.url");
            if (dbUrl.startsWith("jdbc:")) {
                dbUrl = dbUrl.substring("jdbc:".length());
View Full Code Here

Examples of org.evolizer.core.hibernate.session.api.IEvolizerSession

            } else {
                LOGGER.info("Starting import of project " + project.getName() + " history job");
            }
            EvolizerSessionHandler handler = EvolizerSessionHandler.getHandler();
            handler.updateSchema(this.project);
            IEvolizerSession persistenceProvider = handler.getCurrentSession(this.project);

            String[] repositoryData = new String[3];
            repositoryData[0] = this.user;
            repositoryData[1] = this.pwd;

            if (this.directories != null) {
                repositoryData[2] = this.lcp(this.directories[0], this.lcp(this.directories[1], this.directories[2]));
                this.directories[0] = this.directories[0].replace(repositoryData[2], "");
                this.directories[1] = this.directories[1].replace(repositoryData[2], "");
                this.directories[2] = this.directories[2].replace(repositoryData[2], "");
            } else {
                String url =
                        ((SVNTeamProvider) RepositoryProvider.getProvider(project)).getRepositoryResource().getUrl();
                if (url.contains("/trunk")) {
                    repositoryData[2] = url.substring(0, url.indexOf("/trunk"));
                } else if (url.contains("/tags")) {
                    repositoryData[2] = url.substring(0, url.indexOf("/tags"));
                } else if (url.contains("/branches")) {
                    repositoryData[2] = url.substring(0, url.indexOf("/branches"));
                } else {
                    repositoryData[2] = url;
                }
            }
            EvolizerSVNImporter importer =
                    new EvolizerSVNImporter(
                            repositoryData,
                            this.tries,
                            this.diff,
                            this.fileExtensionRegEx,
                            this.directories);

            try {
                importer.importProject(persistenceProvider, monitor, this.start, this.end, this.update);
                LOGGER.info("Import Job of project " + project.getName() + " version history done");
            } catch (SVNException e) {
                LOGGER.error("Error while importing the version history for project " + project.getName(), e);
                System.err.println(e);
                return Status.CANCEL_STATUS;
            } finally {
                persistenceProvider.close();
            }

        } catch (SVNImporterException e) {
            if (e.getMessage().compareTo("The history is up to date") == 0) {
                monitor.subTask("The history is up to date");
View Full Code Here

Examples of org.evolizer.core.hibernate.session.api.IEvolizerSession

    /**
     * Cleans up the job "workspace".
     */
    public void cleanUpJob() {
        try {
            IEvolizerSession session = EvolizerSessionHandler.getHandler().getCurrentSession(this.project);
            if ((session != null) && session.isOpen()) {
                session.clear();
                session.close();
            }
        } catch (EvolizerException e) {
            e.printStackTrace();
        }
    }
View Full Code Here

Examples of org.evolizer.core.hibernate.session.api.IEvolizerSession

    @Override
    protected IStatus run(IProgressMonitor monitor) {
        try {
            EvolizerSessionHandler handler = EvolizerSessionHandler.getHandler();
            handler.updateSchema(this.project);
            IEvolizerSession persistenceProvider = handler.getCurrentSession(this.project);

            String[] repositoryData = new String[3];
            repositoryData[0] = "";
            repositoryData[1] = "";

            String url =
                    ((SVNTeamProvider) RepositoryProvider.getProvider(this.project)).getRepositoryResource().getUrl();
            if (url.contains("/trunk")) {
                repositoryData[2] = url.substring(0, url.indexOf("/trunk"));
            } else if (url.contains("/tags")) {
                repositoryData[2] = url.substring(0, url.indexOf("/tags"));
            } else if (url.contains("/branches")) {
                repositoryData[2] = url.substring(0, url.indexOf("/branches"));
            } else {
                repositoryData[2] = url;
            }

            EvolizerSVNImporter importer = new EvolizerSVNImporter(repositoryData);

            // Checking what type of file content import to run (there are 4 types of file content import)
            switch (this.importType) {
                // fetch file content for the whole history (all the existing revisions)
                case 0:
                    try {
                        importer.fetchRevisionRangeSource(persistenceProvider, this.fileExtensionRegEx, 0, -1, monitor);
                    } catch (SVNImporterException e) {
                        sLogger.error("Import of missing file content for the whole SVN history failed:", e);
                        return Status.CANCEL_STATUS;
                    } finally {
                        persistenceProvider.close();
                    }
                    break;
                // Fetch file content for all existing releases
                case 1:
                    try {
                        importer.fetchReleasesSource(persistenceProvider, this.fileExtensionRegEx, null, monitor);
                    } catch (SVNImporterException e) {
                        sLogger.error("Import of missing file content for all the existing releases failed:", e);
                        return Status.CANCEL_STATUS;
                    } finally {
                        persistenceProvider.close();
                    }
                    break;
                // Fetch file content for a revision range
                case 2:
                    try {
                        importer.fetchRevisionRangeSource(
                                persistenceProvider,
                                this.fileExtensionRegEx,
                                this.start,
                                this.end,
                                monitor);
                    } catch (SVNImporterException e) {
                        sLogger.error("Import of missing file content for the " + this.start + ":" + this.end + " revision range failed:", e);
                        return Status.CANCEL_STATUS;
                    } finally {
                        persistenceProvider.close();
                    }
                    break;
                // Fetch file content for selected releases
                case 3:
                    try {
                        importer.fetchReleasesSource(
                                persistenceProvider,
                                this.fileExtensionRegEx,
                                this.releases,
                                monitor);
                    } catch (SVNImporterException e) {
                        sLogger.error("Import of missing file content for a given set of releases failed:", e);
                        return Status.CANCEL_STATUS;
                    } finally {
                        persistenceProvider.close();
                    }
                    break;
                default:
                    break;
            }
View Full Code Here

Examples of org.evolizer.core.hibernate.session.api.IEvolizerSession

    return FileLocator.openStream(EvolizerModelResourcesPlugin.getDefault().getBundle(), new Path(relativeFSPath), false);
  }
 
  private void save(Object... objects) {
    try {
      IEvolizerSession s = fSessionHandler.getCurrentSession(fDBUrl);
      s.startTransaction();
      for(Object o : objects) {
        s.saveObject(o);
      }
      s.endTransaction();
      s.close();
    } catch (EvolizerException e) {
      fail(e.getMessage());
    }
  }
View Full Code Here

Examples of org.evolizer.core.hibernate.session.api.IEvolizerSession

    }
  }
 
  private <T>T loadUnique(String reloadQuery, Class<T> resultType) {
    try {
      IEvolizerSession s = fSessionHandler.getCurrentSession(fDBUrl);
      T result = s.uniqueResult(reloadQuery, resultType);
     
      return result;
    } catch (EvolizerException e) {
      fail(e.getMessage());
      return null;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.