Package org.apache.maven.archiva.database

Examples of org.apache.maven.archiva.database.ArtifactDAO


        repoTask.setName( "testRepoTask" );
        repoTask.setRepositoryId( "testRepo" );
       
        taskExecutor.executeTask( repoTask );

        ArtifactDAO adao = dao.getArtifactDAO();
        List unprocessedResultList = adao.queryArtifacts( new ArtifactsProcessedConstraint( false ) );
       
        assertNotNull( unprocessedResultList );
        assertEquals("Incorrect number of unprocessed artifacts detected.", 8, unprocessedResultList.size() );
    }
View Full Code Here


        assertTrue( "Default Test Repository should exist.", repoDir.exists() && repoDir.isDirectory() );

        ManagedRepositoryConfiguration repo = createRepository( "testRepo", "Test Repository", repoDir );
        assertNotNull( repo );

        ArtifactDAO adao = dao.getArtifactDAO();

        ArchivaArtifact sqlArtifact = adao.createArtifact( "javax.sql", "jdbc", "2.0", "", "jar" );
        sqlArtifact.getModel().setLastModified( new Date() );
        sqlArtifact.getModel().setSize( 1234 );
        sqlArtifact.getModel().setOrigin( "testcase" );
        sqlArtifact.getModel().setWhenProcessed( null );

        adao.saveArtifact( sqlArtifact );

        ArchivaArtifact artifact = adao.getArtifact( "javax.sql", "jdbc", "2.0", null, "jar" );

        assertNotNull( artifact );

        // Test for artifact existance.
        List artifactList = adao.queryArtifacts( null );
        assertNotNull( "Artifact list should not be null.", artifactList );
        assertEquals( "Artifact list size", 1, artifactList.size() );
       
        // Test for unprocessed artifacts.
        List unprocessedResultList = adao.queryArtifacts( new ArtifactsProcessedConstraint( false ) );
        assertNotNull( "Unprocessed Results should not be null.", unprocessedResultList );
        assertEquals( "Incorrect number of unprocessed artifacts detected.", 1, unprocessedResultList.size() );

        // Execute the database task.
        DatabaseTask dataTask = new DatabaseTask();

        dataTask.setName( "testDataTask" );

        taskExecutor.executeTask( dataTask );
       
        // Test for artifact existance.
        artifactList = adao.queryArtifacts( null );
        assertNotNull( "Artifact list should not be null.", artifactList );
        assertEquals( "Artifact list size", 1, artifactList.size() );
       
        // Test for processed artifacts.
        List processedResultList = adao.queryArtifacts( new ArtifactsProcessedConstraint( true ) );
        assertNotNull( "Processed Results should not be null.", processedResultList );
        assertEquals( "Incorrect number of processed artifacts detected.", 1, processedResultList.size() );
    }
View Full Code Here

       
        List<SearchResultHit> hits = results.getHits();
       
        for( SearchResultHit hit : hits )
        {  
            ArtifactDAO artifactDAO = archivaDAO.getArtifactDAO();
             
            List<String> versions = hit.getVersions();
            if( versions != null )
            {
                for( String version : versions )
                {  
                    for( String repo : observableRepos )
                    {
                        try
                        {
                            ArchivaArtifact pomArtifact = artifactDAO.getArtifact(
                                  hit.getGroupId(), hit.getArtifactId(), version, null, "pom", repo );
                            if( pomArtifact != null )
                            {
                                Artifact artifact = new Artifact( pomArtifact.getModel().getRepositoryId(), pomArtifact.getGroupId(), pomArtifact.getArtifactId(), pomArtifact.getVersion(),
                                                                 pomArtifact.getType() );
View Full Code Here

        // 2. create ArtifactsByChecksumConstraint( "queryTerm" )
        // 3. query artifacts using constraint
        // 4. convert results to list of Artifact objects
       
        List<Artifact> results = new ArrayList<Artifact>();
        ArtifactDAO artifactDAO = archivaDAO.getArtifactDAO();
       
        ArtifactsByChecksumConstraint constraint = new ArtifactsByChecksumConstraint( checksum );
        List<ArchivaArtifact> artifacts = artifactDAO.queryArtifacts( constraint );
       
        for( ArchivaArtifact archivaArtifact : artifacts )
        {
            Artifact artifact = new Artifact( archivaArtifact.getModel().getRepositoryId(), archivaArtifact.getModel().getGroupId(),
                          archivaArtifact.getModel().getArtifactId(), archivaArtifact.getModel().getVersion(), archivaArtifact.getType() );
View Full Code Here

        assertTrue( "Default Test Repository should exist.", repoDir.exists() && repoDir.isDirectory() );

        ManagedRepositoryConfiguration repo = createRepository( "testRepo", "Test Repository", repoDir );
        assertNotNull( repo );

        ArtifactDAO adao = dao.getArtifactDAO();

        ArchivaArtifact sqlArtifact = adao.createArtifact( "javax.sql", "jdbc", "2.0", "", "jar", repo.getId() );
        sqlArtifact.getModel().setLastModified( new Date() );
        sqlArtifact.getModel().setSize( 1234 );
        sqlArtifact.getModel().setOrigin( "testcase" );
        sqlArtifact.getModel().setWhenProcessed( null );

        adao.saveArtifact( sqlArtifact );

        ArchivaArtifact artifact = adao.getArtifact( "javax.sql", "jdbc", "2.0", null, "jar", repo.getId() );

        assertNotNull( artifact );

        // Test for artifact existance.
        List<ArchivaArtifact> artifactList = adao.queryArtifacts( null );
        assertNotNull( "Artifact list should not be null.", artifactList );
        assertEquals( "Artifact list size", 1, artifactList.size() );
       
        // Test for unprocessed artifacts.
        List<ArchivaArtifact> unprocessedResultList = adao.queryArtifacts( new ArtifactsProcessedConstraint( false ) );
        assertNotNull( "Unprocessed Results should not be null.", unprocessedResultList );
        assertEquals( "Incorrect number of unprocessed artifacts detected.", 1, unprocessedResultList.size() );

        // Execute the database task.
        DatabaseTask dataTask = new DatabaseTask();

        dataTask.setName( "testDataTask" );

        taskExecutor.executeTask( dataTask );
       
        // Test for artifact existance.
        artifactList = adao.queryArtifacts( null );
        assertNotNull( "Artifact list should not be null.", artifactList );
        assertEquals( "Artifact list size", 1, artifactList.size() );
       
        // Test for processed artifacts.
        List<ArchivaArtifact> processedResultList = adao.queryArtifacts( new ArtifactsProcessedConstraint( true ) );
        assertNotNull( "Processed Results should not be null.", processedResultList );
        assertEquals( "Incorrect number of processed artifacts detected.", 1, processedResultList.size() );
    }
View Full Code Here

        repoTask.setName( "testRepoTask" );
        repoTask.setRepositoryId( "testRepo" );
       
        taskExecutor.executeTask( repoTask );

        ArtifactDAO adao = dao.getArtifactDAO();
        List<ArchivaArtifact> unprocessedResultList = adao.queryArtifacts( new ArtifactsProcessedConstraint( false ) );
       
        assertNotNull( unprocessedResultList );
        assertEquals("Incorrect number of unprocessed artifacts detected.", 8, unprocessedResultList.size() );
    }
View Full Code Here

    private List<RepositoryStatistics> constructRepositoryStatistics(
                                                                      List<RepositoryContentStatistics> repoContentStats,
                                                                      String repository, Date endDate,
                                                                      int start, int end )
    {
        ArtifactDAO artifactDao = dao.getArtifactDAO();   
       
        List<RepositoryStatistics> repoStatisticsList = new ArrayList<RepositoryStatistics>();
        for( int i = start; i <= end; i++ )
        {  
            RepositoryContentStatistics repoContentStat = (RepositoryContentStatistics) repoContentStats.get( i );
            RepositoryStatistics repoStatistics = new RepositoryStatistics();
            repoStatistics.setRepositoryId( repository );
           
            // get only the latest               
            repoStatistics.setArtifactCount( repoContentStat.getTotalArtifactCount() );
            repoStatistics.setGroupCount( repoContentStat.getTotalGroupCount() );
            repoStatistics.setProjectCount( repoContentStat.getTotalProjectCount() );
            repoStatistics.setTotalSize( repoContentStat.getTotalSize() );
            repoStatistics.setFileCount( repoContentStat.getTotalFileCount() );
            repoStatistics.setDateOfScan( repoContentStat.getWhenGathered() );
               
            try
            {
                //TODO use the repo content stats whenGathered date instead of endDate for single repo reports
                List<ArchivaArtifact> types = artifactDao.queryArtifacts(
                         new ArtifactsByRepositoryConstraint( repository, JAR_TYPE, endDate, "whenGathered" ) );
                repoStatistics.setJarCount( types.size() );
               
                types = artifactDao.queryArtifacts(
                        new ArtifactsByRepositoryConstraint( repository, WAR_TYPE, endDate, "whenGathered" ) );
                repoStatistics.setWarCount( types.size() );
               
                types = artifactDao.queryArtifacts(
                        new ArtifactsByRepositoryConstraint( repository, MAVEN_PLUGIN, endDate, "whenGathered" ) );
                repoStatistics.setPluginCount( types.size() );
               
                // TODO: must need to be able to track archetypes. possible way of identifying an
                //      archetype is by checking if archetype.xml exists in src/main/resources/META-INF/
View Full Code Here

        repoTask.setName( "testRepoTask" );
        repoTask.setRepositoryId( "testRepo" );
       
        taskExecutor.executeTask( repoTask );

        ArtifactDAO adao = dao.getArtifactDAO();
        List unprocessedResultList = adao.queryArtifacts( new ArtifactsProcessedConstraint( false ) );
       
        assertNotNull( unprocessedResultList );
        assertEquals("Incorrect number of unprocessed artifacts detected.", 8, unprocessedResultList.size() );
    }
View Full Code Here

        repoTask.setName( "testRepoTask" );
        repoTask.setRepositoryId( "testRepo" );
       
        taskExecutor.executeTask( repoTask );

        ArtifactDAO adao = dao.getArtifactDAO();
        List unprocessedResultList = adao.queryArtifacts( new ArtifactsProcessedConstraint( false ) );
       
        assertNotNull( unprocessedResultList );
        assertEquals("Incorrect number of unprocessed artifacts detected.", 8, unprocessedResultList.size() );
    }
View Full Code Here

        ArchivaRepository repoSaved = repoDao.saveRepository( repo );
        assertNotNull( repoSaved );
        assertNotNull( repoSaved.getModel() );
        assertEquals( "testRepo", JDOHelper.getObjectId( repoSaved.getModel() ).toString() );

        ArtifactDAO adao = dao.getArtifactDAO();

        ArchivaArtifact sqlArtifact = adao.createArtifact( "javax.sql", "jdbc", "2.0", "", "jar" );
        sqlArtifact.getModel().setLastModified( new Date() );
        sqlArtifact.getModel().setSize( 1234 );
        sqlArtifact.getModel().setOrigin( "testcase" );
        sqlArtifact.getModel().setWhenProcessed( null );

        adao.saveArtifact( sqlArtifact );

        ArchivaArtifact artifact = adao.getArtifact( "javax.sql", "jdbc", "2.0", null, "jar" );

        assertNotNull( artifact );

        // Test for artifact existance.
        List artifactList = adao.queryArtifacts( null );
        assertNotNull( "Artifact list should not be null.", artifactList );
        assertEquals( "Artifact list size", 1, artifactList.size() );
       
        // Test for unprocessed artifacts.
        List unprocessedResultList = adao.queryArtifacts( new ArtifactsProcessedConstraint( false ) );
        assertNotNull( "Unprocessed Results should not be null.", unprocessedResultList );
        assertEquals( "Incorrect number of unprocessed artifacts detected.", 1, unprocessedResultList.size() );

        // Execute the database task.
        DatabaseTask dataTask = new DatabaseTask();

        dataTask.setName( "testDataTask" );

        taskExecutor.executeTask( dataTask );
       
        // Test for artifact existance.
        artifactList = adao.queryArtifacts( null );
        assertNotNull( "Artifact list should not be null.", artifactList );
        assertEquals( "Artifact list size", 1, artifactList.size() );
       
        // Test for processed artifacts.
        List processedResultList = adao.queryArtifacts( new ArtifactsProcessedConstraint( true ) );
        assertNotNull( "Processed Results should not be null.", processedResultList );
        assertEquals( "Incorrect number of processed artifacts detected.", 1, processedResultList.size() );
    }
View Full Code Here

TOP

Related Classes of org.apache.maven.archiva.database.ArtifactDAO

Copyright © 2018 www.massapicom. 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.