Search in sources :

Example 1 with DataColumnDef

use of org.dashbuilder.dataset.def.DataColumnDef in project kie-wb-common by kiegroup.

the class ContributorsManager method buildDataSet.

@Override
public DataSet buildDataSet(Map<String, String> params) {
    final DataSetBuilder dsBuilder = DataSetFactory.newDataSetBuilder();
    for (final DataColumnDef columnDef : dataSetdef.getColumns()) {
        dsBuilder.column(columnDef.getId(), columnDef.getColumnType());
    }
    final Collection<OrganizationalUnit> orgUnitList = organizationalUnitService.getOrganizationalUnits();
    for (final OrganizationalUnit orgUnit : orgUnitList) {
        final String org = orgUnit.getName();
        final Collection<WorkspaceProject> projects = projectService.getAllWorkspaceProjects(orgUnit);
        if (projects.isEmpty()) {
            // org
            dsBuilder.row(// org
            org, // repo
            null, // project
            null, // author
            null, // message
            "Empty organizational unit", // date
            null);
        } else {
            for (final WorkspaceProject project : projects) {
                final String repoAlias = project.getRepository().getAlias();
                final String projectName = project.getName();
                org.uberfire.backend.vfs.Path rootPath = project.getRootPath();
                final Path projectRoot = Paths.convert(rootPath);
                final List<VersionRecord> recordList = recordService.loadVersionRecords(projectRoot);
                if (recordList.isEmpty()) {
                    // org
                    dsBuilder.row(// org
                    org, // repo
                    repoAlias, // project
                    null, // author
                    null, // mesage
                    "Empty project", // date
                    null);
                } else {
                    for (VersionRecord record : recordList) {
                        String alias = record.author();
                        String author = authorMappings.getProperty(alias);
                        author = author == null ? alias : author;
                        String msg = record.comment();
                        Date date = record.date();
                        dsBuilder.row(org, repoAlias, projectName, author, msg, date);
                    }
                }
            }
        }
    }
    DataSet dataSet = dsBuilder.buildDataSet();
    dataSet.setUUID(GIT_CONTRIB);
    return dataSet;
}
Also used : Path(org.uberfire.java.nio.file.Path) OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) DataSet(org.dashbuilder.dataset.DataSet) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) DataSetBuilder(org.dashbuilder.dataset.DataSetBuilder) Date(java.util.Date) VersionRecord(org.uberfire.java.nio.base.version.VersionRecord) DataColumnDef(org.dashbuilder.dataset.def.DataColumnDef)

Aggregations

Date (java.util.Date)1 DataSet (org.dashbuilder.dataset.DataSet)1 DataSetBuilder (org.dashbuilder.dataset.DataSetBuilder)1 DataColumnDef (org.dashbuilder.dataset.def.DataColumnDef)1 WorkspaceProject (org.guvnor.common.services.project.model.WorkspaceProject)1 OrganizationalUnit (org.guvnor.structure.organizationalunit.OrganizationalUnit)1 VersionRecord (org.uberfire.java.nio.base.version.VersionRecord)1 Path (org.uberfire.java.nio.file.Path)1