Examples of PersistenceManagerFactory


Examples of javax.jdo.PersistenceManagerFactory

    }

    @SuppressWarnings({"OverlyCoupledMethod"})
    public void eraseDatabase()
    {
        PersistenceManagerFactory pmf = getPersistenceManagerFactory( "jdo109" );
        PersistenceManager persistenceManager = getPersistenceManager( pmf );
        PlexusJdoUtils.removeAll( persistenceManager, ProjectGroup.class );
        PlexusJdoUtils.removeAll( persistenceManager, Project.class );
        PlexusJdoUtils.removeAll( persistenceManager, Schedule.class );
        PlexusJdoUtils.removeAll( persistenceManager, ScmResult.class );
View Full Code Here

Examples of javax.jdo.PersistenceManagerFactory

        finally
        {
            IOUtil.close( fileReader );
        }

        PersistenceManagerFactory pmf = getPersistenceManagerFactory( "jdorepl109" );

        PlexusJdoUtils.addObject( pmf.getPersistenceManager(), database.getSystemConfiguration() );

        Map<Integer, Schedule> schedules = new HashMap<Integer, Schedule>();
        for ( Iterator i = database.getSchedules().iterator(); i.hasNext(); )
        {
            Schedule schedule = (Schedule) i.next();

            schedule = (Schedule) PlexusJdoUtils.addObject( pmf.getPersistenceManager(), schedule );
            schedules.put( Integer.valueOf( schedule.getId() ), schedule );
        }

        for ( Iterator i = database.getProjectGroups().iterator(); i.hasNext(); )
        {
            ProjectGroup projectGroup = (ProjectGroup) i.next();

            // first, we must map up any schedules, etc.
            processBuildDefinitions( projectGroup.getBuildDefinitions(), schedules );

            for ( Iterator j = projectGroup.getProjects().iterator(); j.hasNext(); )
            {
                Project project = (Project) j.next();

                processBuildDefinitions( project.getBuildDefinitions(), schedules );
            }

            PlexusJdoUtils.addObject( pmf.getPersistenceManager(), projectGroup );
        }
        pmf.close();
    }
View Full Code Here

Examples of javax.jdo.PersistenceManagerFactory

        // Take control of the JDO instead of using the store, and configure a new persistence factory
        // that won't generate new object IDs.
        Properties properties = new Properties();
        properties.putAll( factory.getProperties() );
        properties.setProperty( "org.jpox.metadata.jdoFileExtension", "jdorepl" );
        PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory( properties );

        PlexusJdoUtils.addObject( pmf.getPersistenceManager(), database.getSystemConfiguration() );

        Map<Integer, BuildQueue> buildQueues = new HashMap<Integer, BuildQueue>();
        for ( BuildQueue buildQueue : (List<BuildQueue>)database.getBuildQueues() )
        {
            buildQueue = (BuildQueue) PlexusJdoUtils.addObject( pmf.getPersistenceManager(), buildQueue );
            buildQueues.put( buildQueue.getId(), buildQueue );
        }

        Map<Integer, Schedule> schedules = new HashMap<Integer, Schedule>();
        for ( Iterator i = database.getSchedules().iterator(); i.hasNext(); )
        {
            Schedule schedule = (Schedule) i.next();
            schedule.setBuildQueues( getBuildQueuesBySchedule( buildQueues, schedule ) );

            schedule = (Schedule) PlexusJdoUtils.addObject( pmf.getPersistenceManager(), schedule );
            schedules.put( Integer.valueOf( schedule.getId() ), schedule );
        }

        Map<Integer, Installation> installations = new HashMap<Integer, Installation>();
        for ( Iterator i = database.getInstallations().iterator(); i.hasNext(); )
        {
            Installation installation = (Installation) i.next();

            installation = (Installation) PlexusJdoUtils.addObject( pmf.getPersistenceManager(), installation );
            installations.put( Integer.valueOf( installation.getInstallationId() ), installation );
        }

        Map<Integer, Profile> profiles = new HashMap<Integer, Profile>();
        for ( Iterator i = database.getProfiles().iterator(); i.hasNext(); )
        {
            Profile profile = (Profile) i.next();

            // process installations
            if ( profile.getJdk() != null )
            {
                profile.setJdk( installations.get( profile.getJdk().getInstallationId() ) );
            }
            if ( profile.getBuilder() != null )
            {
                profile.setBuilder( installations.get( profile.getBuilder().getInstallationId() ) );
            }
            List environmentVariables = new ArrayList();
            for (Iterator envIt = profile.getEnvironmentVariables().listIterator(); envIt.hasNext();){
                Installation installation = (Installation) envIt.next();
                environmentVariables.add(installations.get(installation.getInstallationId()));
                envIt.remove();
            }
            profile.setEnvironmentVariables( environmentVariables );
            profile = (Profile) PlexusJdoUtils.addObject( pmf.getPersistenceManager(), profile );
            profiles.put( Integer.valueOf( profile.getId() ), profile );
        }

        Map<Integer, BuildDefinition> buildDefinitions = new HashMap<Integer, BuildDefinition>();
        for ( BuildDefinition buildDefinition : (List<BuildDefinition>) database.getBuildDefinitions() )
        {
            if ( buildDefinition.getSchedule() != null )
            {
                buildDefinition.setSchedule( schedules.get( Integer.valueOf( buildDefinition.getSchedule().getId() ) ) );
            }

            if ( buildDefinition.getProfile() != null )
            {
                buildDefinition.setProfile( profiles.get( Integer.valueOf( buildDefinition.getProfile().getId() ) ) );
            }

            buildDefinition = (BuildDefinition) PlexusJdoUtils.addObject( pmf.getPersistenceManager(), buildDefinition );
            buildDefinitions.put( Integer.valueOf( buildDefinition.getId() ), buildDefinition );
        }

        Map<Integer, LocalRepository> localRepositories = new HashMap<Integer, LocalRepository>();
        for ( LocalRepository localRepository : (List<LocalRepository>) database.getLocalRepositories() )
        {
            localRepository =
                (LocalRepository) PlexusJdoUtils.addObject( pmf.getPersistenceManager(), localRepository );
            localRepositories.put( Integer.valueOf( localRepository.getId() ), localRepository );
        }

        Map<Integer, ProjectGroup> projectGroups = new HashMap<Integer, ProjectGroup>();
        for ( Iterator i = database.getProjectGroups().iterator(); i.hasNext(); )
        {
            ProjectGroup projectGroup = (ProjectGroup) i.next();

            // first, we must map up any schedules, etc.
            projectGroup.setBuildDefinitions( processBuildDefinitions( projectGroup.getBuildDefinitions(),
                                                                       schedules, profiles, buildDefinitions ) );

            for ( Iterator j = projectGroup.getProjects().iterator(); j.hasNext(); )
            {
                Project project = (Project) j.next();

                project.setBuildDefinitions( processBuildDefinitions( project.getBuildDefinitions(),
                                                                      schedules, profiles, buildDefinitions ) );
            }

            if ( projectGroup.getLocalRepository() != null )
            {
                projectGroup.setLocalRepository( localRepositories.get(
                                                 Integer.valueOf( projectGroup.getLocalRepository().getId() ) ) );
            }

            projectGroup = (ProjectGroup) PlexusJdoUtils.addObject( pmf.getPersistenceManager(), projectGroup );
            projectGroups.put( Integer.valueOf( projectGroup.getId() ), projectGroup );
        }

        // create project scm root data (CONTINUUM-2040)
        Map<Integer, ProjectScmRoot> projectScmRoots = new HashMap<Integer, ProjectScmRoot>();
        Set<Integer> keys = projectGroups.keySet();
        int id = 1;
        for( Integer key : keys )
        {
            ProjectGroup projectGroup = projectGroups.get( key );
            String url = " ";
            List<Project> projects =
                ProjectSorter.getSortedProjects( getProjectsByGroupIdWithDependencies( pmf, projectGroup.getId() ),
                                                 log );
            for ( Iterator j = projects.iterator(); j.hasNext(); )
            {
                Project project = (Project) j.next();
                if ( !project.getScmUrl().trim().startsWith( url ) )
                {
                    url = project.getScmUrl();
                    ProjectScmRoot projectScmRoot = new ProjectScmRoot();
                    projectScmRoot.setId( id );
                    projectScmRoot.setProjectGroup( projectGroup );
                    projectScmRoot.setScmRootAddress( url );
                    projectScmRoot.setState( project.getState() );

                    projectScmRoot = (ProjectScmRoot) PlexusJdoUtils.addObject( pmf.getPersistenceManager(), projectScmRoot );
                    projectScmRoots.put( Integer.valueOf( projectScmRoot.getId() ), projectScmRoot );
                    id++;
                }
            }
        }

        /*
        for ( RepositoryPurgeConfiguration repoPurge : (List<RepositoryPurgeConfiguration>) database.getRepositoryPurgeConfigurations() )
        {
            repoPurge.setRepository( localRepositories.get(
                                     Integer.valueOf( repoPurge.getRepository().getId() ) ) );

            if ( repoPurge.getSchedule() != null )
            {
                repoPurge.setSchedule( schedules.get(
                                       Integer.valueOf( repoPurge.getSchedule().getId() ) ) );
            }

            repoPurge = (RepositoryPurgeConfiguration) PlexusJdoUtils.addObject( pmf.getPersistenceManager(), repoPurge );
        }*/

        for ( DirectoryPurgeConfiguration dirPurge : (List<DirectoryPurgeConfiguration>) database.getDirectoryPurgeConfigurations() )
        {
            if ( dirPurge.getSchedule() != null )
            {
                dirPurge.setSchedule( schedules.get(
                                      Integer.valueOf( dirPurge.getSchedule().getId() ) ) );
            }

            dirPurge = (DirectoryPurgeConfiguration) PlexusJdoUtils.addObject( pmf.getPersistenceManager(), dirPurge );
        }

        for ( ContinuumReleaseResult releaseResult : (List<ContinuumReleaseResult>) database.getContinuumReleaseResults() )
        {
            releaseResult.setProjectGroup( projectGroups.get(
                                           Integer.valueOf( releaseResult.getProjectGroup().getId() ) ) );

            ProjectGroup group = releaseResult.getProjectGroup();

            for ( Project project : (List<Project>) group.getProjects() )
            {
                if ( project.getId() == releaseResult.getProject().getId() )
                {
                    try
                    {
                        Project proj =
                            (Project) PlexusJdoUtils.getObjectById( pmf.getPersistenceManager(), Project.class, project.getId(), null );
                        releaseResult.setProject( proj );
                    }
                    catch ( Exception e )
                    {
                        throw new DataManagementException( e );
                    }
                }
            }

            releaseResult =
                (ContinuumReleaseResult) PlexusJdoUtils.addObject( pmf.getPersistenceManager(), releaseResult );
        }

        for ( BuildDefinitionTemplate template : (List<BuildDefinitionTemplate>) database.getBuildDefinitionTemplates() )
        {
            template.setBuildDefinitions( processBuildDefinitions( template.getBuildDefinitions(), buildDefinitions ) );

            template =
                (BuildDefinitionTemplate) PlexusJdoUtils.addObject( pmf.getPersistenceManager(), template );
        }
    }
View Full Code Here

Examples of javax.jdo.PersistenceManagerFactory

            //We need a JNDI context which contains a PMF instance.
            //For this reason, we create a JNDI context,
            //create a PMF instance and bind that to the context.
            context = new InitialContext();
            if (name.equals(validPropertiesFile)) {
                PersistenceManagerFactory pmf =
                    JDOHelper.getPersistenceManagerFactory(new File(name));
                context.bind(jndiName, pmf);
            }
            return JDOHelper.getPersistenceManagerFactory(jndiName, context,
                    Thread.currentThread().getContextClassLoader());
View Full Code Here

Examples of javax.jdo.PersistenceManagerFactory

    }
   
    /** */
    public void test() {
      Properties pmfProperties = loadPMF2Properties();
        PersistenceManagerFactory pmf2 = JDOHelper.getPersistenceManagerFactory(pmfProperties);
        PersistenceManager pm2 = pmf2.getPersistenceManager();
        Transaction tx2 = pm2.currentTransaction();
       
        pm = getPM();
        Transaction tx = pm.currentTransaction();
        try {
            tx.begin();
            tx2.begin();
           
            PCPoint p11 = new PCPoint(110, 120);
            PCPoint p12 = new PCPoint(120, 140);
            PCRect rect1 = new PCRect (0, p11, p12);
            pm.makePersistent (rect1);
           
            PCPoint p21 = new PCPoint(210, 220);
            PCPoint p22 = new PCPoint(220, 240);
            PCRect rect2 = new PCRect (0, p21, p22);
            pm2.makePersistent (rect2);
           
            tx.commit();
            tx2.commit();
       
            tx.begin();
            tx2.begin();
           
            PCPoint p11a = findPoint (pm, 110, 120);
            if (p11a != p11) {
                fail(ASSERTION_FAILED,
                     "unexpected PCPoint instance, expected: 110, 120, found: " + p11a.getX() + ", " + p11a.getY());
            }
           
            PCPoint p21a = findPoint (pm2, 210, 220);
            if (p21a != p21) {
                fail(ASSERTION_FAILED,
                     "unexpected PCPoint instance, expected: 210, 220, found: " + p21a.getX() + ", " + p21a.getY());
            }
           
            tx.commit();
            tx = null;
            tx2.commit();
            tx2 = null;
        }
        finally {
            cleanupPM(pm);
            pm = null;
            cleanupPM(pm2);
            pm2 = null;
            pmf2.close();
        }
    }
View Full Code Here

Examples of javax.jdo.PersistenceManagerFactory

            //We need a JNDI context which contains a PMF instance.
            //For this reason, we create a JNDI context,
            //create a PMF instance and bind that to the context.
            context = new InitialContext();
            if (name.equals(validPropertiesFile)) {
                PersistenceManagerFactory pmf =
                    JDOHelper.getPersistenceManagerFactory(new File(name));
                verifyProperties(pmf, loadProperties(validPropertiesFile));
                context.bind(jndiName, pmf);
            }
            return JDOHelper.getPersistenceManagerFactory(jndiName, context);
View Full Code Here

Examples of javax.jdo.PersistenceManagerFactory

        // ----------------------------------------------------------------------
        // Check the configuration
        // ----------------------------------------------------------------------

        PersistenceManagerFactory pmf = jdoFactory.getPersistenceManagerFactory();

        assertNotNull( pmf );

        assertEquals( url, pmf.getConnectionURL() );

        PersistenceManager pm = pmf.getPersistenceManager();

        pm.close();

        // ----------------------------------------------------------------------
        //
View Full Code Here

Examples of javax.jdo.PersistenceManagerFactory

    OAuthServiceProvider provider =
        new OAuthServiceProvider(requestTokenUrl, authorizeUrl, accessTokenUrl);
    OAuthConsumer consumer = new OAuthConsumer(callbackUrl, consumerKey, consumerSecret, provider);
    OAuthAccessor accessor = new OAuthAccessor(consumer);
    OAuthClient client = new OAuthClient(new OpenSocialHttpClient());
    PersistenceManagerFactory pmf = SingletonPersistenceManagerFactory.get();
    return new OAuthServiceImpl(accessor, client, pmf, userRecordKey);
  }
View Full Code Here

Examples of javax.jdo.PersistenceManagerFactory

  public final void testCheckAuthorizationNoRequestToken() {
    // Setup.
    LoginFormHandler loginForm = mock(LoginFormHandler.class);
    OAuthClient client = mock(OAuthClient.class);
    PersistenceManager pm = mock(PersistenceManager.class);
    PersistenceManagerFactory pmf = mock(PersistenceManagerFactory.class);

    OAuthAccessor accessor = buildAccessor(CONSUMER_KEY, CONSUMER_SECRET,
        REQUEST_TOKEN_URL, AUTHORIZE_URL, CALLBACK_URL, ACCESS_TOKEN_URL);
    accessor.requestToken = REQUEST_TOKEN_STRING;
    oauthService = new OAuthServiceImpl(accessor, client, pmf,
        USER_RECORD_KEY);
    OAuthUser userWithRequestToken = new OAuthUser(USER_RECORD_KEY, REQUEST_TOKEN_STRING);

    // Expectations.
    when(pmf.getPersistenceManager()).thenReturn(pm);
    when(pm.getObjectById(OAuthUser.class, USER_RECORD_KEY)).thenReturn(null, userWithRequestToken,
        userWithRequestToken);

    assertFalse(oauthService.checkAuthorization(null, loginForm));
View Full Code Here

Examples of javax.jdo.PersistenceManagerFactory

                "org.apache.jdo.tck.api.persistencemanager.ConcurrentPersistenceManagersSameClasses",
                "javax.jdo.option.BinaryCompatibility");
            return;
        }
        Properties pmfProperties = loadPMF2Properties();
        PersistenceManagerFactory pmf2 = JDOHelper.getPersistenceManagerFactory(pmfProperties);
        PersistenceManager pm2 = pmf2.getPersistenceManager();
        Transaction tx2 = pm2.currentTransaction();
        PCPoint p21 = null;
        PCPoint p22 = null;
        PCRect rect2 = null;

        pm = getPM();
        Transaction tx = pm.currentTransaction();
        try {
            tx.begin();
            tx2.begin();
           
            PCPoint p11 = new PCPoint(110, 120);
            PCPoint p12 = new PCPoint(120, 140);
            PCRect rect1 = new PCRect (0, p11, p12);
            pm.makePersistent (rect1);
           
            p21 = new PCPoint(210, 220);
            p22 = new PCPoint(220, 240);
            rect2 = new PCRect (0, p21, p22);
            pm2.makePersistent (rect2);
           
            tx.commit();
            tx2.commit();
       
            tx.begin();
            tx2.begin();
           
            PCPoint p11a = findPoint (pm, 110, 120);
            if (p11a != p11) {
                fail(ASSERTION_FAILED,
                     "unexpected PCPoint instance, expected: 110, 120, found: " + p11a.getX() + ", " + p11a.getY());
            }
           
            PCPoint p21a = findPoint (pm2, 210, 220);
            if (p21a != p21) {
                fail(ASSERTION_FAILED,
                     "unexpected PCPoint instance, expected: 210, 220, found: " + p21a.getX() + ", " + p21a.getY());
            }
           
            tx.commit();
            tx = null;
            tx2.commit();
            tx2 = null;
        }
        finally {
            cleanupPM(pm);
            pm = null;
            try {
                // delete pm2 instances
                if (pm2.currentTransaction().isActive()) {
                    pm2.currentTransaction().rollback();
                }
                pm2.currentTransaction().begin();
                pm2.deletePersistent(rect2);
                pm2.deletePersistent(p21);
                pm2.deletePersistent(p22);
                pm2.currentTransaction().commit();
            } finally {
                cleanupPM(pm2);
                pm2 = null;
                pmf2.close();
            }
        }
    }
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.