@Test public void testSetRootItem() throws Exception { treeItem = mock(IsTreeItem.class); view = mock(ModuleTreeItemView.class); ClientFactory clientFactory = mock(ClientFactory.class); AssetEditorFactory assetEditorFactory = mock(AssetEditorFactory.class); when(clientFactory.getAssetEditorFactory()).thenReturn(assetEditorFactory); PerspectiveFactory perspectiveFactory = mock(PerspectiveFactory.class); when(perspectiveFactory.getRegisteredAssetEditorFormats("package")).thenReturn(new String[0]); NavigationViewFactory navigationViewFactory = mock(NavigationViewFactory.class); when(clientFactory.getNavigationViewFactory()).thenReturn(navigationViewFactory); when(navigationViewFactory.getModuleTreeItemView()).thenReturn(view); PackageConfigData packageConfigData = mock(PackageConfigData.class); when(packageConfigData.getUuid()).thenReturn("mockUuid"); new ModuleTreeSelectableItem(clientFactory, treeItem, packageConfigData); verify(view).setRootItem(treeItem); ArgumentCaptor<ModuleEditorPlace> moduleEditorPlaceArgumentCaptor = ArgumentCaptor.forClass(ModuleEditorPlace.class); verify(view).setRootUserObject(moduleEditorPlaceArgumentCaptor.capture()); ModuleEditorPlace assetViewerPlace = moduleEditorPlaceArgumentCaptor.getValue(); assertEquals("mockUuid", assetViewerPlace.getUuid()); }
protected PackageConfigData loadPackageConfig(PackageItem packageItem) { PackageConfigData data = PackageConfigDataFactory.createPackageConfigDataWithDependencies(packageItem); if (data.isSnapshot()) { data.setSnapshotName(packageItem.getSnapshotName()); } return data; }
/** Get a download link for the binary package. */ public static String getDownloadLink(PackageConfigData conf) { String hurl = GWT.getModuleBaseURL() + "package/" + conf.getName(); // NON-NLS if (!conf.isSnapshot()) { hurl = hurl + "/" + SnapshotView.LATEST_SNAPSHOT; } else { hurl = hurl + "/" + conf.getSnapshotName(); } final String uri = hurl; return uri; }
protected PackageConfigData loadGlobalPackage() { PackageItem item = rulesRepository.loadGlobalArea(); PackageConfigData data = PackageConfigDataFactory.createPackageConfigDataWithOutDependencies(item); if (data.isSnapshot()) { data.setSnapshotName(item.getSnapshotName()); } return data; }
public ValidatedResponse validatePackageConfiguration(PackageConfigData data) throws SerializationException { log.info( "USER:"******" validatePackageConfiguration package [" + data.getName() + "]"); RuleBaseCache.getInstance().remove(data.getUuid()); BRMSSuggestionCompletionLoader loader = createBRMSSuggestionCompletionLoader(); loader.getSuggestionEngine(rulesRepository.loadPackage(data.getName()), data.getHeader()); return validateBRMSSuggestionCompletionLoaderResponse(loader); }
private void handleIsPackagesListed( boolean archive, String workspace, RepositoryFilter filter, List<PackageConfigData> result, PackageConfigData data) { if (!archive && (filter == null || filter.accept(data, RoleType.PACKAGE_READONLY.getName())) && (workspace == null || isWorkspace(workspace, data.getWorkspaces()))) { result.add(data); } else if (archive && data.isArchived() && (filter == null || filter.accept(data, RoleType.PACKAGE_READONLY.getName())) && (workspace == null || isWorkspace(workspace, data.getWorkspaces()))) { result.add(data); } }
void handleArchivedForSavePackage(PackageConfigData data, PackageItem item) { for (Iterator<AssetItem> iter = item.getAssets(); iter.hasNext(); ) { AssetItem assetItem = iter.next(); if (!assetItem.isArchived()) { assetItem.archiveItem(true); assetItem.checkin(data.getDescription()); } } }
void handleUnarchivedForSavePackage( PackageConfigData data, PackageItem item, Calendar packageLastModified) { for (Iterator<AssetItem> iter = item.getAssets(); iter.hasNext(); ) { AssetItem assetItem = iter.next(); // Unarchive the assets archived after the package // ( == at the same time that the package was archived) if (assetItem.getLastModified().compareTo(packageLastModified) >= 0) { assetItem.archiveItem(false); assetItem.checkin(data.getDescription()); } } }
/** * This is called to display the success (and a download option). * * @param buildResults */ private void showSuccessfulBuild(Panel buildResults) { buildResults.clear(); VerticalPanel vert = new VerticalPanel(); vert.add( new HTML( AbstractImagePrototype.create(images.greenTick()).getHTML() + "<i>" + constants.PackageBuiltSuccessfully() + " " + conf.getLastModified() + "</i>")); final String hyp = getDownloadLink(this.conf); HTML html = new HTML( "<a href='" + hyp + "' target='_blank'>" + constants.DownloadBinaryPackage() + "</a>"); vert.add(html); buildResults.add(vert); }
private void handleIteratePackages( boolean archive, String workspace, RepositoryFilter filter, List<PackageConfigData> result, PackageIterator pkgs) { pkgs.setArchivedIterator(archive); while (pkgs.hasNext()) { PackageItem packageItem = pkgs.next(); PackageConfigData data = new PackageConfigData(); data.setUuid(packageItem.getUUID()); data.setName(packageItem.getName()); data.setArchived(packageItem.isArchived()); data.setWorkspaces(packageItem.getWorkspaces()); handleIsPackagesListed(archive, workspace, filter, result, data); data.subPackages = listSubPackages(packageItem, archive, null, filter); } }
void updateCategoryRules(PackageConfigData data, PackageItem item) { KeyValueTO keyValueTO = convertMapToCsv(data.getCatRules()); item.updateCategoryRules(keyValueTO.getKeys(), keyValueTO.getValues()); }
public void savePackage(PackageConfigData data) throws SerializationException { log.info("USER:"******" SAVING package [" + data.getName() + "]"); PackageItem item = rulesRepository.loadPackage(data.getName()); // If package is being unarchived. boolean unarchived = (!data.isArchived() && item.isArchived()); Calendar packageLastModified = item.getLastModified(); DroolsHeader.updateDroolsHeader(data.getHeader(), item); updateCategoryRules(data, item); item.updateExternalURI(data.getExternalURI()); item.updateDescription(data.getDescription()); item.archiveItem(data.isArchived()); item.updateBinaryUpToDate(false); if (!data.getFormat().equals("")) { item.updateFormat(data.getFormat()); } RuleBaseCache.getInstance().remove(data.getUuid()); item.checkin(data.getDescription()); // If package is archived, archive all the assets under it if (data.isArchived()) { handleArchivedForSavePackage(data, item); } else if (unarchived) { handleUnarchivedForSavePackage(data, item, packageLastModified); } }