Search in sources :

Example 1 with VersionRecord

use of org.uberfire.java.nio.base.version.VersionRecord in project drools-wb by kiegroup.

the class GuidedDecisionTableEditorServiceImplTest method checkSaveAndUpdateGraphEntries.

@Test
@SuppressWarnings("unchecked")
public void checkSaveAndUpdateGraphEntries() {
    // Setup Decision Table
    final Path path = mock(Path.class);
    final GuidedDecisionTable52 model = new GuidedDecisionTable52();
    final Metadata metadata = mock(Metadata.class);
    final String comment = "comment";
    final String headPathUri = "default://project/src/main/resources/mypackage/dtable.gdst";
    final String versionPathUri = "default://0123456789@project/src/main/resources/mypackage/dtable.gdst";
    when(path.toURI()).thenReturn(headPathUri);
    when(path.getFileName()).thenReturn("dtable.gdst");
    // Setup Decision Table versions
    final List<VersionRecord> versions = new ArrayList<>();
    versions.add(new PortableVersionRecord("0123456789", "manstis", "manstis@email.com", "comment", Calendar.getInstance().getTime(), versionPathUri));
    when(versionRecordService.load(any(org.uberfire.java.nio.file.Path.class))).thenReturn(versions);
    // Setup Decision Table Graph
    final URI dtGraphPathUri = URI.create("default://project/src/main/resources/mypackage/graph1.gdst-set");
    final org.uberfire.java.nio.file.Path dtGraphPath = mock(org.uberfire.java.nio.file.Path.class);
    when(dtGraphPath.toUri()).thenReturn(dtGraphPathUri);
    when(dtGraphPath.getFileName()).thenReturn(dtGraphPath);
    when(dtGraphPath.getFileSystem()).thenReturn(fileSystem);
    final List<org.uberfire.java.nio.file.Path> dtGraphPaths = new ArrayList<>();
    dtGraphPaths.add(dtGraphPath);
    when(ioService.newDirectoryStream(any(org.uberfire.java.nio.file.Path.class), any(FileExtensionFilter.class))).thenReturn(new MockDirectoryStream(dtGraphPaths));
    final GuidedDecisionTableEditorGraphModel dtGraphModel = new GuidedDecisionTableEditorGraphModel();
    dtGraphModel.getEntries().add(new GuidedDecisionTableEditorGraphModel.GuidedDecisionTableGraphEntry(path, path));
    when(dtableGraphService.load(any(Path.class))).thenReturn(dtGraphModel);
    // Test save
    service.saveAndUpdateGraphEntries(path, model, metadata, comment);
    verify(ioService, times(1)).startBatch(any(FileSystem.class));
    verify(ioService, times(1)).write(any(org.uberfire.java.nio.file.Path.class), any(String.class), any(Map.class), any(CommentedOption.class));
    verify(ioService, times(1)).endBatch();
    assertEquals("mypackage", model.getPackageName());
    assertEquals(1, dtGraphModel.getEntries().size());
    assertEquals(versions.get(0).uri(), dtGraphModel.getEntries().iterator().next().getPathVersion().toURI());
}
Also used : Path(org.uberfire.backend.vfs.Path) GuidedDecisionTableEditorGraphModel(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) ArrayList(java.util.ArrayList) URI(java.net.URI) PortableVersionRecord(org.uberfire.ext.editor.commons.version.impl.PortableVersionRecord) VersionRecord(org.uberfire.java.nio.base.version.VersionRecord) CommentedOption(org.uberfire.java.nio.base.options.CommentedOption) FileSystem(org.uberfire.java.nio.file.FileSystem) FileExtensionFilter(org.guvnor.common.services.backend.file.FileExtensionFilter) PortableVersionRecord(org.uberfire.ext.editor.commons.version.impl.PortableVersionRecord) Map(java.util.Map) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 2 with VersionRecord

use of org.uberfire.java.nio.base.version.VersionRecord 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)

Example 3 with VersionRecord

use of org.uberfire.java.nio.base.version.VersionRecord in project kie-wb-common by kiegroup.

the class ContributorsManagerTest method setUp.

@Before
public void setUp() throws Exception {
    SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
    List<VersionRecord> repositoryHistory1 = new ArrayList<>();
    repositoryHistory1.add(new PortableVersionRecord(null, "David", null, "", sdf.parse("02/01/2017"), "default://3da0441b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "David", null, "", sdf.parse("01/01/2017"), "default://3da0442b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "David", null, "", sdf.parse("02/01/2017"), "default://3da0443b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "Roger", null, "", sdf.parse("02/02/2017"), "default://3da0441b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "Roger", null, "", sdf.parse("02/03/2017"), "default://3da0442b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "Mark", null, "", sdf.parse("02/03/2017"), "default://3da04471@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "Roger", null, "", sdf.parse("02/04/2017"), "default://3da0442b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "Roger", null, "", sdf.parse("02/05/2017"), "default://3da0443b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "Mark", null, "", sdf.parse("01/02/2017"), "default://3da0444b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "Mark", null, "", sdf.parse("01/05/2017"), "default://3da0442b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "Mark", null, "", sdf.parse("01/06/2017"), "default://3da0443b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "Roger", null, "", sdf.parse("01/06/2017"), "default://3da0447b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/06/2017"), "default://3da0445b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "David", null, "", sdf.parse("01/06/2017"), "default://3da0457b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "Mark", null, "", sdf.parse("01/06/2017"), "default://3da0441b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/03/2017"), "default://3da0442b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/04/2017"), "default://3da0442b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/05/2017"), "default://3da0442b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/06/2017"), "default://3da0443b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/0/2017"), "default://3da04474@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/08/2016"), "default://3da0445b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/08/2016"), "default://3da0446b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/09/2016"), "default://3da0447b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/10/2016"), "default://3da0445b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/11/2016"), "default://3da0444b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "David", null, "", sdf.parse("01/11/2016"), "default://3da0442b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "David", null, "", sdf.parse("01/12/2016"), "default://3da0442b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "Roger", null, "", sdf.parse("01/12/2016"), "default://3da0441b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "Roger", null, "", sdf.parse("02/04/2017"), "default://3da0444b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "Roger", null, "", sdf.parse("02/05/2017"), "default://3da0444b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "Mark", null, "", sdf.parse("01/02/2017"), "default://3da0443b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "Mark", null, "", sdf.parse("01/05/2017"), "default://3da0442b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "Mark", null, "", sdf.parse("01/06/2017"), "default://3da0442b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "David", null, "", sdf.parse("02/01/2017"), "default://3da0441b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "David", null, "", sdf.parse("01/01/2017"), "default://3da0442b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "David", null, "", sdf.parse("02/01/2017"), "default://3da0443b@project1/file"));
    List<VersionRecord> repositoryHistory2 = new ArrayList<>();
    repositoryHistory2.add(new PortableVersionRecord(null, "Roger", null, "", sdf.parse("02/02/2017"), "default://3da0441b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "Roger", null, "", sdf.parse("02/03/2017"), "default://3da0442b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "Mark", null, "", sdf.parse("02/03/2017"), "default://3da04471@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "Roger", null, "", sdf.parse("02/04/2017"), "default://3da0442b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "Roger", null, "", sdf.parse("02/05/2017"), "default://3da0443b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "Mark", null, "", sdf.parse("01/02/2017"), "default://3da0444b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "Mark", null, "", sdf.parse("01/05/2017"), "default://3da0442b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "Mark", null, "", sdf.parse("01/06/2017"), "default://3da0443b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "Roger", null, "", sdf.parse("01/06/2017"), "default://3da0447b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/06/2017"), "default://3da0445b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "David", null, "", sdf.parse("01/06/2017"), "default://3da0457b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "Mark", null, "", sdf.parse("01/06/2017"), "default://3da0441b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/03/2017"), "default://3da0442b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/04/2017"), "default://3da0442b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/05/2017"), "default://3da0442b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/06/2017"), "default://3da0443b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/0/2017"), "default://3da04474@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/08/2016"), "default://3da0445b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/08/2016"), "default://3da0446b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/09/2016"), "default://3da0447b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/10/2016"), "default://3da0445b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/11/2016"), "default://3da0444b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "David", null, "", sdf.parse("01/11/2016"), "default://3da0442b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "David", null, "", sdf.parse("01/12/2016"), "default://3da0442b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "Roger", null, "", sdf.parse("01/12/2016"), "default://3da0441b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "David", null, "", sdf.parse("02/01/2017"), "default://3da0441b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "Roger", null, "", sdf.parse("02/02/2017"), "default://3da0442b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "Roger", null, "", sdf.parse("02/03/2017"), "default://3da0443b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "Mark", null, "", sdf.parse("02/03/2017"), "default://3da0444b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "Roger", null, "", sdf.parse("02/04/2017"), "default://3da0444b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "Roger", null, "", sdf.parse("02/05/2017"), "default://3da0444b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "Mark", null, "", sdf.parse("01/02/2017"), "default://3da0443b@project2/file"));
    System.out.println("SUM = " + (repositoryHistory1.size() + repositoryHistory2.size()));
    final Repository repo1 = makeRepository("testRepo1");
    final Repository repo2 = makeRepository("testRepo2");
    final OrganizationalUnit org1 = makeOrganizationalUnit("test1", Arrays.asList(repo1, repo2));
    when(organizationalUnitService.getOrganizationalUnits()).thenReturn(Arrays.asList(org1));
    final Set<WorkspaceProject> projects = new HashSet<>();
    projects.add(makeProject(repo1, org1, "project1"));
    projects.add(makeProject(repo2, org1, "project2"));
    when(projectService.getAllWorkspaceProjects(eq(org1))).thenReturn(projects);
    when(recordService.loadVersionRecords(any())).thenReturn(repositoryHistory1).thenReturn(repositoryHistory2);
}
Also used : Repository(org.guvnor.structure.repositories.Repository) OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) PortableVersionRecord(org.uberfire.ext.editor.commons.version.impl.PortableVersionRecord) VersionRecord(org.uberfire.java.nio.base.version.VersionRecord) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) ArrayList(java.util.ArrayList) PortableVersionRecord(org.uberfire.ext.editor.commons.version.impl.PortableVersionRecord) SimpleDateFormat(java.text.SimpleDateFormat) HashSet(java.util.HashSet) Before(org.junit.Before)

Example 4 with VersionRecord

use of org.uberfire.java.nio.base.version.VersionRecord in project kie-wb-common by kiegroup.

the class KieMultipleDocumentEditorTest method testVersionRecordManagerSelectionChange.

@Test
@SuppressWarnings("unchecked")
public void testVersionRecordManagerSelectionChange() {
    final TestDocument document = createTestDocument();
    final ObservablePath path = document.getLatestPath();
    registerDocument(document);
    activateDocument(document);
    final ArgumentCaptor<Callback> callbackArgumentCaptor = ArgumentCaptor.forClass(Callback.class);
    verify(versionRecordManager, times(1)).init(eq(null), eq(path), callbackArgumentCaptor.capture());
    final Callback<VersionRecord> callback = callbackArgumentCaptor.getValue();
    assertNotNull(callback);
    final VersionRecord versionRecord = mock(VersionRecord.class);
    final ObservablePath newPath = mock(ObservablePath.class);
    when(versionRecord.id()).thenReturn("id");
    when(versionRecordManager.getCurrentPath()).thenReturn(newPath);
    when(versionRecordManager.isLatest(versionRecord)).thenReturn(false);
    callback.callback(versionRecord);
    verify(versionRecordManager, times(1)).setVersion(eq("id"));
    verify(document, times(1)).setVersion(eq("id"));
    verify(document, times(1)).setCurrentPath(eq(newPath));
    verify(document, times(1)).setReadOnly(eq(true));
    verify(editor, times(1)).refreshDocument(document);
}
Also used : RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback) Callback(org.uberfire.client.callbacks.Callback) VersionRecord(org.uberfire.java.nio.base.version.VersionRecord) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Test(org.junit.Test)

Example 5 with VersionRecord

use of org.uberfire.java.nio.base.version.VersionRecord in project drools-wb by kiegroup.

the class GuidedDecisionTableGraphEditorPresenterTest method checkInitialiseVersionManager.

@Test
public void checkInitialiseVersionManager() {
    doNothing().when(presenter).reload();
    when(versionRecordManager.isLatest(any(VersionRecord.class))).thenReturn(true);
    presenter.initialiseVersionManager();
    verify(versionRecordManager, times(1)).init(eq(null), eq(presenter.editorPath), versionRecordCallbackCaptor.capture());
    final Callback<VersionRecord> versionRecordCallback = versionRecordCallbackCaptor.getValue();
    assertNotNull(versionRecordCallback);
    versionRecordCallback.callback(new PortableVersionRecord("id", "author", "email", "comment", mock(Date.class), "uri"));
    verify(versionRecordManager, times(1)).setVersion(eq("id"));
    verify(registeredDocumentsMenuBuilder, times(1)).setReadOnly(eq(false));
    verify(presenter, times(1)).reload();
    assertFalse(presenter.access.isReadOnly());
}
Also used : PortableVersionRecord(org.uberfire.ext.editor.commons.version.impl.PortableVersionRecord) VersionRecord(org.uberfire.java.nio.base.version.VersionRecord) PortableVersionRecord(org.uberfire.ext.editor.commons.version.impl.PortableVersionRecord) Test(org.junit.Test)

Aggregations

VersionRecord (org.uberfire.java.nio.base.version.VersionRecord)5 Test (org.junit.Test)3 PortableVersionRecord (org.uberfire.ext.editor.commons.version.impl.PortableVersionRecord)3 ArrayList (java.util.ArrayList)2 WorkspaceProject (org.guvnor.common.services.project.model.WorkspaceProject)2 OrganizationalUnit (org.guvnor.structure.organizationalunit.OrganizationalUnit)2 URI (java.net.URI)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 DataSet (org.dashbuilder.dataset.DataSet)1 DataSetBuilder (org.dashbuilder.dataset.DataSetBuilder)1 DataColumnDef (org.dashbuilder.dataset.def.DataColumnDef)1 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)1 GuidedDecisionTableEditorGraphModel (org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel)1 FileExtensionFilter (org.guvnor.common.services.backend.file.FileExtensionFilter)1 Metadata (org.guvnor.common.services.shared.metadata.model.Metadata)1 Repository (org.guvnor.structure.repositories.Repository)1