Skip to content

Commit

Permalink
Bug 560060 - [Passage] provide "issued licenses" report
Browse files Browse the repository at this point in the history
 - repackage existing yars export (customer base) wizard
 - pull common parts out for further ues in 'issued licenses' report
wizard
 - start implementing 'issued licenses' report export wizard

Signed-off-by: elena.parovyshnaya <elena.parovyshnaya@gmail.com>
  • Loading branch information
eparovyshnaya committed Jun 5, 2020
1 parent 61bed4c commit 4f50506
Show file tree
Hide file tree
Showing 32 changed files with 1,006 additions and 102 deletions.
Expand Up @@ -24,7 +24,9 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="0.0.0",
org.eclipse.passage.loc.licenses.core;bundle-version="0.0.0",
org.eclipse.passage.loc.products.ui;bundle-version="0.0.0",
org.eclipse.passage.loc.users.ui;bundle-version="0.0.0",
org.eclipse.passage.loc.workbench;bundle-version="0.0.0"
org.eclipse.passage.loc.workbench;bundle-version="0.0.0",
org.eclipse.passage.loc.report.core;bundle-version="0.2.0",
org.eclipse.passage.loc.report.ui
Import-Package: javax.inject;version="1.0.0"
Export-Package: org.eclipse.passage.loc.internal.licenses.ui;x-friends:="org.eclipse.passage.loc.dashboard.ui",
org.eclipse.passage.loc.internal.licenses.ui.i18n;x-internal:=true,
Expand Down
@@ -0,0 +1,59 @@
/*******************************************************************************
* Copyright (c) 2020 ArSysOp
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* https://www.eclipse.org/legal/epl-2.0/.
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* ArSysOp - initial API and implementation
*******************************************************************************/
package org.eclipse.passage.loc.internal.licenses.ui.handlers;

import java.util.Optional;

import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.osgi.util.NLS;
import org.eclipse.passage.loc.internal.licenses.ui.i18n.LicensesUiMessages;
import org.eclipse.passage.loc.report.internal.core.license.LicenseReportExportService;
import org.eclipse.passage.loc.report.internal.core.license.LicenseStorage;
import org.eclipse.passage.loc.report.internal.ui.jface.license.ExposedIssuedLicensesReportWizard;
import org.eclipse.swt.widgets.Shell;

public class IssuedLicensesReportHandler {

@Execute
public void execute(IEclipseContext context) {
Optional<LicenseStorage> storage = service(LicenseStorage.class, context);
if (!storage.isPresent()) {
return;
}
Optional<LicenseReportExportService> export = service(LicenseReportExportService.class, context);
if (!export.isPresent()) {
return;
}

new ExposedIssuedLicensesReportWizard(//
storage.get(), //
export.get()//
).accept(context.get(Shell.class));

}

private <S> Optional<S> service(Class<S> service, IEclipseContext context) {
Optional<S> implementation = Optional.ofNullable(context.get(service));
if (!implementation.isPresent()) {
MessageDialog.openError(//
context.get(Shell.class), //
LicensesUiMessages.IssuedLicensesReportHandler_unavailableTitle, //
NLS.bind(LicensesUiMessages.IssuedLicensesReportHandler_unavailableMessage, service.getName())//
);
}
return implementation;
}

}
Expand Up @@ -16,14 +16,19 @@
import org.eclipse.osgi.util.NLS;

public class LicensesUiMessages extends NLS {

private static final String BUNDLE_NAME = "org.eclipse.passage.loc.internal.licenses.ui.i18n.LicensesUiMessages"; //$NON-NLS-1$

public static String LicenseExportHandler_e_period_invalid;
public static String LicenseExportHandler_error_message;
public static String LicenseExportHandler_error_title;
public static String LicenseExportHandler_period_message;
public static String LicenseExportHandler_period_title;
public static String LicenseExportHandler_success_title;
public static String LicensesUi_select_license_plan;
public static String IssuedLicensesReportHandler_unavailableTitle;
public static String IssuedLicensesReportHandler_unavailableMessage;

static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, LicensesUiMessages.class);
Expand Down
Expand Up @@ -19,3 +19,7 @@ LicenseExportHandler_period_message=Please specify license period in months
LicenseExportHandler_period_title=License Period
LicenseExportHandler_success_title=License Pack Issued
LicensesUi_select_license_plan=Select License Plan

IssuedLicensesReportHandler_unavailableTitle=Export is unavailable
IssuedLicensesReportHandler_unavailableMessage=Severe configuration error: no implementation for {0} service found

Expand Up @@ -31,16 +31,16 @@
* @since 0.2
*/
@SuppressWarnings("restriction")
final class LicensePlanReport implements ExportData<LicensePlanReport, DosHandleMedia<LicensePlanReport>> {
public final class LicensePlanReport implements ExportData<LicensePlanReport, DosHandleMedia<LicensePlanReport>> {

private final LicensePlanDescriptor plan;
private final int amount;
private final Map<UserDescriptor, List<UserLicenseDescriptor>> licenses;
private final boolean explain;
private final SimpleDateFormat format = new SimpleDateFormat("YYYY-MM-dd"); //$NON-NLS-1$

public LicensePlanReport(LicensePlanDescriptor plan, int amount,
Map<UserDescriptor, List<UserLicenseDescriptor>> licenses, boolean explain) {
LicensePlanReport(LicensePlanDescriptor plan, int amount, Map<UserDescriptor, List<UserLicenseDescriptor>> licenses,
boolean explain) {
this.plan = plan;
this.amount = amount;
this.licenses = licenses;
Expand Down
Expand Up @@ -14,6 +14,8 @@ Require-Bundle: org.eclipse.passage.loc.yars.api;bundle-version="0.1.0";visibili
org.eclipse.osgi.services;bundle-version="3.8.0",
org.eclipse.passage.lic.products;bundle-version="0.5.200",
org.eclipse.osgi,
org.eclipse.core.runtime
Export-Package: org.eclipse.passage.loc.report.internal.ui.jface.user
org.eclipse.core.runtime,
org.eclipse.passage.lic.licenses;bundle-version="0.5.200"
Export-Package: org.eclipse.passage.loc.report.internal.ui.jface.license,
org.eclipse.passage.loc.report.internal.ui.jface.user
Bundle-ActivationPolicy: lazy
Expand Up @@ -15,7 +15,9 @@
import org.eclipse.osgi.util.NLS;

public class ExportCustomersWizardMessages extends NLS {

private static final String BUNDLE_NAME = "org.eclipse.passage.loc.report.internal.ui.i18n.ExportCustomersWizardMessages"; //$NON-NLS-1$

public static String AllProducts_noExportService;
public static String ErrorPage_description;
public static String ErrorPage_title;
Expand All @@ -28,11 +30,8 @@ public class ExportCustomersWizardMessages extends NLS {
public static String ScopePage_selctNone;
public static String ScopePage_selectAll;
public static String ScopePage_title;
public static String TargetPage_browse;
public static String TargetPage_description;
public static String TargetPage_open;
public static String TargetPage_title;
public static String VisibleProgress_task;

static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, ExportCustomersWizardMessages.class);
Expand Down
Expand Up @@ -11,20 +11,21 @@
# ArSysOp - initial API and implementation
###############################################################################
AllProducts_noExportService=Severe configuration error: no ExportService is provided

ErrorPage_description=We cannot proceed with the export: unavoidable error happened
ErrorPage_title=Error

ExportCustomersWizard_errorTitle=Error during export

PreviewPage_description=Here are the final list of users to be exported \
and the final location of the result
PreviewPage_title=Users to be exported

ScopePage_columnProduct=Product
ScopePage_columnSelect=Select
ScopePage_description=Here is the list of Products. Select ones, who's users you are interested in.
ScopePage_selctNone=Select &None
ScopePage_selectAll=Select &All
ScopePage_title=Choose users for export
TargetPage_browse=Browse...
TargetPage_description=Select target directory to store exported CSV file
TargetPage_open=Open the resulting file when export is over
TargetPage_title=Exported files location

VisibleProgress_task=Export {0} customers for selected products
@@ -0,0 +1,50 @@
/*******************************************************************************
* Copyright (c) 2020 ArSysOp
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* https://www.eclipse.org/legal/epl-2.0/.
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* ArSysOp - initial API and implementation
*******************************************************************************/
package org.eclipse.passage.loc.report.internal.ui.i18n;

import org.eclipse.osgi.util.NLS;

public class ExportLicenseReportWizardMessages extends NLS {

private static final String BUNDLE_NAME = "org.eclipse.passage.loc.report.internal.ui.i18n.ExportLicenseReportWizardMessages"; //$NON-NLS-1$

public static String ErrorPage_description;
public static String ErrorPage_title;
public static String ExportCustomersWizard_errorTitle;
public static String PreviewPage_description;

public static String PreviewPage_period;
public static String PreviewPage_title;
public static String ScopePage_columnProduct;
public static String ScopePage_columnSelect;
public static String ScopePage_selctNone;
public static String ScopePage_selectAll;
public static String ScopePage_title;
public static String ScopePage_description;

public static String ConfigPage_title;
public static String ConfigPage_description;
public static String ConfigPage_dateFrom_title;
public static String ConfigPage_dateTo_title;
public static String ConfigPage_dates_description;

public static String VisibleProgress_task;

static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, ExportLicenseReportWizardMessages.class);
}

private ExportLicenseReportWizardMessages() {
}
}
@@ -0,0 +1,33 @@
###############################################################################
# Copyright (c) 2020 ArSysOp
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License 2.0 which is available at
# http://www.eclipse.org/legal/epl-2.0.
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# ArSysOp - initial API and implementation
###############################################################################
ErrorPage_description=We cannot proceed with the export: unavoidable error happened
ErrorPage_title=Error

ExportCustomersWizard_errorTitle=Error during export

PreviewPage_description=Here are the final list of license plans selected \
and the final location of the resulting report
PreviewPage_title=License Plans, selected for analysis

ScopePage_columnProduct=License Plan
ScopePage_columnSelect=Select
ScopePage_description=Here is the list of available License Plans. \
Select those, which you'd like to include into issues licenses report.
ScopePage_selctNone=Select &None
ScopePage_selectAll=Select &All
ScopePage_title=Choose license plan for report

ConfigPage_title = Report configuration settings
ConfigPage_description = Alter supported report configuration parameters

VisibleProgress_task=Export issued licenses report for {0} selected license plans
@@ -0,0 +1,45 @@
/*******************************************************************************
* Copyright (c) 2020 ArSysOp
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* https://www.eclipse.org/legal/epl-2.0/.
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* ArSysOp - initial API and implementation
*******************************************************************************/
package org.eclipse.passage.loc.report.internal.ui.i18n;

import org.eclipse.osgi.util.NLS;

public class ExportWizardMessages extends NLS {

private static final String BUNDLE_NAME = "org.eclipse.passage.loc.report.internal.ui.i18n.ExportWizardMessages"; //$NON-NLS-1$

public static String ErrorPage_description;
public static String ErrorPage_title;
public static String ExportCustomersWizard_errorTitle;
public static String PreviewPage_description;
public static String PreviewPage_title;
public static String ScopePage_columnProduct;
public static String ScopePage_columnSelect;
public static String ScopePage_description;
public static String ScopePage_selctNone;
public static String ScopePage_selectAll;
public static String ScopePage_title;
public static String TargetPage_browse;
public static String TargetPage_description;
public static String TargetPage_open;
public static String TargetPage_title;
public static String VisibleProgress_task;

static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, ExportWizardMessages.class);
}

private ExportWizardMessages() {
}
}
@@ -0,0 +1,17 @@
###############################################################################
# Copyright (c) 2020 ArSysOp
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License 2.0 which is available at
# http://www.eclipse.org/legal/epl-2.0.
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# ArSysOp - initial API and implementation
###############################################################################

TargetPage_browse=Browse...
TargetPage_description=Select target directory to store exported CSV file
TargetPage_open=Open the resulting file when export is over
TargetPage_title=Exported files location
@@ -0,0 +1,66 @@
/*******************************************************************************
* Copyright (c) 2020 ArSysOp
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* https://www.eclipse.org/legal/epl-2.0/.
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* ArSysOp - initial API and implementation
*******************************************************************************/
package org.eclipse.passage.loc.report.internal.ui.jface;

import java.nio.file.Files;
import java.nio.file.Path;
import java.util.function.Supplier;

/**
* <p>
* Base class collecting all the data gathered by an export wizard. Can tell if
* the current state of the data is sufficient ({@code complete}) for export or
* not.
* </p>
* <p>
* Each export wizard is must get from a user the following information:
* </p>
* <ul>
* <li>path to a directory where exported file is going to appear, and</li>
* <li>if a user desires to open exported report right after the export is
* done</li>
* </ul>
* <p>
* To gather more data, extend the class, supply the data and the validation
* part for it.
* </p>
*
* @author user
*
*/
public abstract class ExportWizardDecisions {

private final Supplier<Path> target;
private final Supplier<Boolean> open;

protected ExportWizardDecisions(Supplier<Path> target, Supplier<Boolean> open) {
this.target = target;
this.open = open;
}

public final Path target() {
return target.get();
}

public final boolean open() {
return open.get();
}

public final boolean complete() {
Path path = target();
return Files.exists(path) && Files.isDirectory(path) && dataComplete();
}

protected abstract boolean dataComplete();

}

0 comments on commit 4f50506

Please sign in to comment.