Package org.apache.maven.archiva.model

Examples of org.apache.maven.archiva.model.RepositoryContentStatistics


                List<RepositoryContentStatistics> results = (List<RepositoryContentStatistics>) dao.query(
                    new MostRecentRepositoryScanStatistics( arepo.getId() ) );

                if ( CollectionUtils.isNotEmpty( results ) )
                {
                    RepositoryContentStatistics lastStats = results.get( 0 );
                    if ( !repoTask.isScanAll() )
                    {
                        sinceWhen = lastStats.getWhenGathered().getTime() - lastStats.getDuration();
                    }
                }

                RepositoryScanStatistics stats = repoScanner.scan( arepo, sinceWhen );

                log.info( "Finished repository task: " + stats.toDump( arepo ) );

                RepositoryContentStatistics dbstats = constructRepositoryStatistics( arepo, stats );

                dao.getRepositoryContentStatisticsDAO().saveRepositoryContentStatistics( dbstats );

                this.task = null;
            }
View Full Code Here


    @SuppressWarnings("unchecked")
    private RepositoryContentStatistics constructRepositoryStatistics( ManagedRepositoryConfiguration arepo,
                                                                       RepositoryScanStatistics stats )
    {
        // I hate jpox and modello <-- and so do I
        RepositoryContentStatistics dbstats = new RepositoryContentStatistics();
        dbstats.setDuration( stats.getDuration() );
        dbstats.setNewFileCount( stats.getNewFileCount() );
        dbstats.setRepositoryId( stats.getRepositoryId() );
        dbstats.setTotalFileCount( stats.getTotalFileCount() );
        dbstats.setWhenGathered( stats.getWhenGathered() );

        // total artifact count
        // note that when gathered is the end of the scan, so we look for all those before that time
        dbstats.setTotalArtifactCount( dao.getArtifactDAO().countArtifacts(
            new ArtifactsByRepositoryConstraint( arepo.getId(), stats.getWhenGathered(), "groupId", true ) ) );

        // total repo size -- TODO: needs to exclude ignored files (eg .svn)
        long size = FileUtils.sizeOfDirectory( new File( arepo.getLocation() ) );
        dbstats.setTotalSize( size );

        // total unique groups
        List<String> repos = new ArrayList<String>();
        repos.add( arepo.getId() );

        dbstats.setTotalGroupCount( dao.count( new UniqueGroupIdConstraint( repos ) ) );

        dbstats.setTotalProjectCount( dao.count( new UniqueArtifactIdConstraint( arepo.getId(), true ) ) );

        return dbstats;
    }
View Full Code Here

   
                List<RepositoryContentStatistics> results = (List<RepositoryContentStatistics>) dao.query( new MostRecentRepositoryScanStatistics( arepo.getId() ) );
   
                if ( CollectionUtils.isNotEmpty( results ) )
                {
                    RepositoryContentStatistics lastStats = results.get( 0 );
                    sinceWhen = lastStats.getWhenGathered().getTime() + lastStats.getDuration();
                }
   
                RepositoryScanStatistics stats = repoScanner.scan( arepo, sinceWhen );
   
                log.info( "Finished repository task: " + stats.toDump( arepo ) );
               
                RepositoryContentStatistics dbstats = constructRepositoryStatistics( arepo, sinceWhen, results, stats );
               
                dao.getRepositoryContentStatisticsDAO().saveRepositoryContentStatistics( dbstats );  
               
                this.task = null;
            }
View Full Code Here

                                                                       long sinceWhen,
                                                                       List<RepositoryContentStatistics> results,
                                                                       RepositoryScanStatistics stats )       
    {
        // I hate jpox and modello <-- and so do I
        RepositoryContentStatistics dbstats = new RepositoryContentStatistics();
        dbstats.setDuration( stats.getDuration() );
        dbstats.setNewFileCount( stats.getNewFileCount() );
        dbstats.setRepositoryId( stats.getRepositoryId() );
        dbstats.setTotalFileCount( stats.getTotalFileCount() );
        dbstats.setWhenGathered( stats.getWhenGathered() );
               
        // total artifact count
        try
        {
            List<ArchivaArtifact> artifacts = dao.getArtifactDAO().queryArtifacts(
                      new ArtifactsByRepositoryConstraint( arepo.getId(), stats.getWhenGathered(), "groupId", true ) );           
            dbstats.setTotalArtifactCount( artifacts.size() );
        }
        catch ( ObjectNotFoundException oe )
        {
            log.error( "Object not found in the database : " + oe.getMessage() );
        }
        catch ( ArchivaDatabaseException ae )
        {  
            log.error( "Error occurred while querying artifacts for artifact count : " + ae.getMessage() );
        }
       
        // total repo size
        long size = FileUtils.sizeOfDirectory( new File( arepo.getLocation() ) );
        dbstats.setTotalSize( size );
         
          // total unique groups
        List<String> repos = new ArrayList<String>();
        repos.add( arepo.getId() );
       
        List<String> groupIds = (List<String>) dao.query( new UniqueGroupIdConstraint( repos ) );
        dbstats.setTotalGroupCount( groupIds.size() );
               
        List<Object[]> artifactIds = (List<Object[]>) dao.query( new UniqueArtifactIdConstraint( arepo.getId(), true ) );
        dbstats.setTotalProjectCount( artifactIds.size() );
                       
        return dbstats;
    }  
View Full Code Here

        return repoStatsList;
    }

    private RepositoryContentStatistics createRepositoryContentStatistics()
    {
        RepositoryContentStatistics repoStats = new RepositoryContentStatistics();
        repoStats.setRepositoryId( REPO_ID );
        repoStats.setDuration( 1000 );
        repoStats.setTotalArtifactCount( 100 );
        repoStats.setTotalSize( 10 );
        repoStats.setTotalFileCount( 10 );
        repoStats.setTotalProjectCount( 2 );
        repoStats.setTotalGroupCount( 1 );
        repoStats.setNewFileCount( 3 );
        repoStats.setWhenGathered( new Date( System.currentTimeMillis() ) );

        return repoStats;
    }
View Full Code Here

            List<RepositoryContentStatistics> results = dao.query( new MostRecentRepositoryScanStatistics( arepo.getId() ) );

            if ( CollectionUtils.isNotEmpty( results ) )
            {
                RepositoryContentStatistics lastStats = results.get( 0 );
                sinceWhen = lastStats.getWhenGathered().getTime() + lastStats.getDuration();
            }

            RepositoryScanStatistics stats = repoScanner.scan( arepo, sinceWhen );

            getLogger().info( "Finished repository task: " + stats.toDump( arepo ) );
           
            // I hate jpox and modello
            RepositoryContentStatistics dbstats = new RepositoryContentStatistics();
            dbstats.setDuration( stats.getDuration() );
            dbstats.setNewFileCount( stats.getNewFileCount() );
            dbstats.setRepositoryId( stats.getRepositoryId() );
            dbstats.setTotalFileCount( stats.getTotalFileCount() );
            dbstats.setWhenGathered( stats.getWhenGathered() );
           
            dao.getRepositoryContentStatisticsDAO().saveRepositoryContentStatistics( dbstats );
        }
        catch ( RepositoryException e )
        {
View Full Code Here

        assertFalse( action.hasActionErrors() );
        assertFalse( action.hasFieldErrors() );

        RepositoryContentStatisticsDAOStub dao =
            (RepositoryContentStatisticsDAOStub) lookup( RepositoryContentStatisticsDAO.class, "jdo" );
        RepositoryContentStatistics stats = dao.queryRepositoryContentStatistics(
            new RepositoryContentStatisticsByRepositoryConstraint( SNAPSHOTS ) ).get( 0 );

        assertEquals(
            "Date of Scan,Total File Count,Total Size,Artifact Count,Group Count,Project Count,Plugins,Archetypes,Jars,Wars,Deployments,Downloads\n" +
                stats.getWhenGathered() + ",0,0,0,0,0,1,0,1,1,0,0\n", IOUtils.toString( action.getInputStream() ) );
    }
View Full Code Here

        return artifact;
    }
   
    private RepositoryContentStatistics createRepositoryContentStatistics( Date startDate, String repositoryId )
    {
        RepositoryContentStatistics repoContentStats = new RepositoryContentStatistics();
        repoContentStats.setRepositoryId( repositoryId );
        repoContentStats.setDuration( 10000 );
        repoContentStats.setNewFileCount( 100 );
        repoContentStats.setTotalArtifactCount( 200 );
        repoContentStats.setTotalFileCount( 250 );
        repoContentStats.setTotalGroupCount( 100 );
        repoContentStats.setTotalProjectCount( 180 );
        repoContentStats.setTotalSize( 200000 );
        repoContentStats.setWhenGathered( startDate );
       
        return repoContentStats;
    }
View Full Code Here

{
    private RepositoryContentStatistics createStats( String repoId, String timestamp, long duration, long totalfiles,
                                                     long newfiles )
        throws Exception
    {
        RepositoryContentStatistics stats = new RepositoryContentStatistics();
        stats.setRepositoryId( repoId );
        stats.setDuration( duration );
        stats.setNewFileCount( newfiles );
        stats.setTotalFileCount( totalfiles );
        stats.setWhenGathered( toDate( timestamp ) );

        return stats;
    }
View Full Code Here

        assertNotNull( "Stats: results (not null)", results );
        assertEquals( "Stats: results.size", 1, results.size() );

        Object o = results.get( 0 );
        assertTrue( "Stats: result[0] instanceof RepositoryScanStatistics", o instanceof RepositoryContentStatistics );
        RepositoryContentStatistics stats = (RepositoryContentStatistics) o;
        assertEquals( "Stats: id", "internal", stats.getRepositoryId() );
        assertEquals( "Stats: when gathered", "2007/02/21 10:00:00", fromDate( stats.getWhenGathered() ) );
        assertEquals( "Stats: duration", 20000, stats.getDuration() );
        assertEquals( "Stats: total file count", 12000, stats.getTotalFileCount() );
        assertEquals( "Stats: new file count", 400, stats.getNewFileCount() );
    }
View Full Code Here

TOP

Related Classes of org.apache.maven.archiva.model.RepositoryContentStatistics

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.