Skip to content

Commit

Permalink
Evaluate formulas when creating XLS. This fixes #94. Fixed bug when r…
Browse files Browse the repository at this point in the history
…eading saved data model (repoType was not handled).
  • Loading branch information
ohecker committed Nov 9, 2021
1 parent b5b88bf commit 09dd107
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 30 deletions.
25 changes: 14 additions & 11 deletions documentation/master-solicitor.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ The _Solicitor_ code and accompanying resources (including this userguide) as st
IMPORTANT: Specifically observe the "Disclaimer of Warranty" and "Limitation of Liability" which are part of the license.

IMPORTANT: The executable JAR file which is created by the Maven based build process includes numerous other Open Source components which are subject to different Open Source licenses. Any distribution of the _Solicitor_ executable JAR file needs to comply with the license conditions of all those components.
If you are running _Solicitor_ from the executable JAR you might use the `-eug` option to store detailed license information as file `solicitor_licenseinfo.html` in your current working directory (together with a copy of this user guide).
If you are running _Solicitor_ from the executable JAR you might use the `-eug` option to store detailed license information as file `solicitor_licenseinfo.html` in your current working directory (together with a copy of this user guide).

== Architecture
The following picture show a business oriented view of _Solicitor_.
Expand Down Expand Up @@ -508,7 +508,7 @@ line in the file for each license.

=== NPM

For NPM based projects either the NPM License Crawler (https://www.npmjs.com/package/npm-license-crawler) or the NPM License Checker (https://www.npmjs.com/package/license-checker) might be used. The NPM License Crawler can process several node packages in one run.
For NPM based projects either the NPM License Crawler (https://www.npmjs.com/package/npm-license-crawler) or the NPM License Checker (https://www.npmjs.com/package/license-checker) might be used. The NPM License Crawler can process several node packages in one run.

==== NPM License Crawler

Expand Down Expand Up @@ -629,7 +629,7 @@ In _Solicitor_ the data is read with the following part of the config
} ]
----

NOTE: The former reader of type `gradle` is deprecated and should no longer be used. See <<List of Deprecated Features>>.
NOTE: The former reader of type `gradle` is deprecated and should no longer be used. See <<List of Deprecated Features>>.

=== Gradle (Android)
For the Export of the the Licenses from a Gradle based Android Projects the Gradle License Plugin is used.
Expand Down Expand Up @@ -678,7 +678,7 @@ In Solicitor the Data is read with the following part of the config
} ]
----

NOTE: The former reader of type `gradle` is deprecated and should no longer be used. See <<List of Deprecated Features>>.
NOTE: The former reader of type `gradle` is deprecated and should no longer be used. See <<List of Deprecated Features>>.


== Working with Decision Tables
Expand Down Expand Up @@ -1001,7 +1001,7 @@ Within the lifecycle of the _Solicitor_ development features might be discontinu
to various reasons. In case that such discontinuation is expected to break existing projects
a two stage deprecation mechanism is used:

* Stage 1: Usage of a deprecated feature will produce a _warning only_ giving details on
* Stage 1: Usage of a deprecated feature will produce a _warning only_ giving details on
what needs to be changed.
* Stage 2: When a deprecated feature is used _Solicitor_ by default will terminate with an error
message giving information about the deprecation.
Expand All @@ -1016,12 +1016,12 @@ IMPORTANT: Enabling the use of deprecated feature via the above property should
a temporary workaround and not a standard setting.

NOTE: If usage of a feature should be discontinued immediately (e.g. because it might lead to
wrong/misleading output) the first stage of deprecation will be skipped.
wrong/misleading output) the first stage of deprecation will be skipped.

=== List of Deprecated Features
The following features are deprecated via the above mechanism:

* Reader of type "gradle" (use Reader of type "gradle2" instead); Stage 2 from Version 1.0.5 on; see https://github.com/devonfw/solicitor/issues/58
* Reader of type "gradle" (use Reader of type "gradle2" instead); Stage 2 from Version 1.0.5 on; see https://github.com/devonfw/solicitor/issues/58
* Reader of type "npm" (use type "npm-license-crawler-csv" instead); Stage 1 from Version 1.0.8 on; see https://github.com/devonfw/solicitor/issues/62

[appendix]
Expand Down Expand Up @@ -1100,10 +1100,13 @@ java -Dloader.path=path/to/the/extension.zip -jar solicitor.jar <any other argum

[appendix]
== Release Notes
Changes in 1.2.1::
* https://github.com/devonfw/solicitor/issues/94: Fixed by making sure that formulas get evaluated when opening the workbook with excel.
* Fixed bug when reading saved data model for delta calculation. (`repoType` was not read correctly and resulted in always reporting a difference.)

Changes in 1.2.0::
* Added some license name mapping rules in LicenseNameMappingSample.xls
* https://github.com/devonfw/solicitor/issues/71:
* https://github.com/devonfw/solicitor/issues/71:
New "Quality Report" which might be helpful in validating the outcome of the _Solicitor_ run.
Currently this report contains a list of all application components which have more than one effective license attached.
This might be helpful for spotting cases where appropriate rules for selecting the applicable license in case of dual-/multilicensing is missing.
Expand All @@ -1123,11 +1126,11 @@ Changes in 1.0.8::
* https://github.com/devonfw/solicitor/issues/62: New Reader of type `npm-license-checker`
for reading component/license data collected by NPM License Checker (https://www.npmjs.com/package/license-checker).
The type of the existing Reader for reading CSV data from the NPM License Crawler has been changed from `npm`
to `npm-license-crawler-csv`. (`npm` is still available but deprecated.) Projects should adopt their Reader
configuration and replace type `npm` by `npm-license-crawler-csv`.
to `npm-license-crawler-csv`. (`npm` is still available but deprecated.) Projects should adopt their Reader
configuration and replace type `npm` by `npm-license-crawler-csv`.

Changes in 1.0.7::
* https://github.com/devonfw/solicitor/issues/56: Enable continuing analysis in
* https://github.com/devonfw/solicitor/issues/56: Enable continuing analysis in
multiapplication projects even is some license files are unavailable.
* Described simplified usage of license-maven-plugin without need to change pom.xml. (Documentation only)
* Ensure consistent sorting even in case that multiple "Ignored" licenses exist for a component
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.devonfw.tools</groupId>
<artifactId>solicitor</artifactId>
<version>1.2.0</version>
<version>1.2.1</version>
<name>Solicitor</name>
<description>A tool for rule based checking of license conditions in software projects.</description>
<parent>
Expand Down Expand Up @@ -221,14 +221,14 @@
<artifactId>asciidoctorj-pdf</artifactId>
<version>${asciidoctorj.pdf.version}</version>
</dependency>
<!-- Comment this section to use the default jruby artifact provided
<!-- Comment this section to use the default jruby artifact provided
by the plugin -->
<dependency>
<groupId>org.jruby</groupId>
<artifactId>jruby-complete</artifactId>
<version>${jruby.version}</version>
</dependency>
<!-- Comment this section to use the default AsciidoctorJ artifact provided
<!-- Comment this section to use the default AsciidoctorJ artifact provided
by the plugin -->
<dependency>
<groupId>org.asciidoctor</groupId>
Expand Down Expand Up @@ -328,7 +328,7 @@
</plugins>
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings
<!--This plugin's configuration is used to store Eclipse m2e settings
only. It has no influence on the Maven build itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public ModelRoot loadModel(String filename) {
try {
JsonNode root = objectMapper.readTree(new File(filename));
int modelVersion = root.get("modelVersion").asInt();
ModelRoot modelRoot = modelFactory.newModelRoot();
ModelRoot modelRoot = this.modelFactory.newModelRoot();
if (modelVersion != modelRoot.getModelVersion()) {
throw new SolicitorRuntimeException("Unsupported model version " + modelVersion + " can not be loaded");
}
Expand Down Expand Up @@ -78,7 +78,7 @@ public ModelRoot loadModel(String filename) {

/**
* Read the {@link ApplicationComponent}s from the JSON data structure.
*
*
* @param application the {@link Application} to which the
* {@link ApplicationComponent}s belong to
* @param applicationComponentsNode the relevant part of the parse JSON
Expand All @@ -93,17 +93,19 @@ private void readApplicationComponents(Application application, JsonNode applica
String groupId = applicationComponentNode.get("groupId").asText(null);
String artifactId = applicationComponentNode.get("artifactId").asText(null);
String version = applicationComponentNode.get("version").asText(null);
String repoType = applicationComponentNode.get("repoType").asText(null);
JsonNode normalizedLicensesNode = applicationComponentNode.get("normalizedLicenses");
JsonNode rawLicensesNode = applicationComponentNode.get("rawLicenses");

ApplicationComponent applicationComponent = modelFactory.newApplicationComponent();
ApplicationComponent applicationComponent = this.modelFactory.newApplicationComponent();
applicationComponent.setApplication(application);
applicationComponent.setUsagePattern(UsagePattern.valueOf(usagePattern));
applicationComponent.setOssModified(ossModified);
applicationComponent.setOssHomepage(ossHomepage);
applicationComponent.setGroupId(groupId);
applicationComponent.setArtifactId(artifactId);
applicationComponent.setVersion(version);
applicationComponent.setRepoType(repoType);

readNormalizedLicenses(applicationComponent, normalizedLicensesNode);
readRawLicenses(applicationComponent, rawLicensesNode);
Expand All @@ -114,7 +116,7 @@ private void readApplicationComponents(Application application, JsonNode applica

/**
* Read the {@link Application}s from the JSON data structure.
*
*
* @param engagement the {@link Engagement} to which the
* {@link Application}s belong to
* @param applicationsNode the relevant part of the parsed JSON model
Expand All @@ -129,7 +131,7 @@ private void readApplications(Engagement engagement, JsonNode applicationsNode)
String programmingEcosystem = applicationNode.get("programmingEcosystem").asText(null);
JsonNode applicationComponentsNode = applicationNode.get("applicationComponents");
Application application =
modelFactory.newApplication(name, releaseId, releaseDate, sourceRepo, programmingEcosystem);
this.modelFactory.newApplication(name, releaseId, releaseDate, sourceRepo, programmingEcosystem);
application.setEngagement(engagement);
readApplicationComponents(application, applicationComponentsNode);

Expand All @@ -139,7 +141,7 @@ private void readApplications(Engagement engagement, JsonNode applicationsNode)

/**
* Read the {@link Engagement} from the JSON data structure.
*
*
* @param modelRoot the root object of the data model to which the
* {@link Engagement} should be added
* @param engagementNode the relevant part of the parsed JSON model
Expand All @@ -155,7 +157,7 @@ private void readEngagement(ModelRoot modelRoot, JsonNode engagementNode) {
boolean customerProvidesOss = engagementNode.get("customerProvidesOss").asBoolean();
JsonNode applicationsNode = engagementNode.get("applications");

Engagement engagement = modelFactory.newEngagement(engagementName, EngagementType.valueOf(engagementType),
Engagement engagement = this.modelFactory.newEngagement(engagementName, EngagementType.valueOf(engagementType),
clientName, GoToMarketModel.valueOf(goToMarketModel));
engagement.setModelRoot(modelRoot);
engagement.setContractAllowsOss(contractAllowsOss);
Expand All @@ -166,7 +168,7 @@ private void readEngagement(ModelRoot modelRoot, JsonNode engagementNode) {

/**
* Read the {@link NormalizedLicense}s from the JSON data structure.
*
*
* @param applicationComponent The {@link ApplicationComponent} to which the
* license belongs
* @param normalizedLicensesNode the relevant part of the parsed JSON model
Expand Down Expand Up @@ -196,7 +198,7 @@ private void readNormalizedLicenses(ApplicationComponent applicationComponent, J
String legalComments = normalizedLicenseNode.get("legalComments").asText(null);
String trace = normalizedLicenseNode.get("trace").asText(null);

NormalizedLicense normalizedLicense = modelFactory.newNormalizedLicense();
NormalizedLicense normalizedLicense = this.modelFactory.newNormalizedLicense();
normalizedLicense.setApplicationComponent(applicationComponent);
normalizedLicense.setDeclaredLicense(declaredLicense);
normalizedLicense.setLicenseUrl(licenseUrl);
Expand All @@ -222,7 +224,7 @@ private void readNormalizedLicenses(ApplicationComponent applicationComponent, J

/**
* Read the {@link RawLicense}s from the JSON data structure.
*
*
* @param applicationComponent The {@link ApplicationComponent} to which the
* license belong
* @param rawLicensesNode the relevant part of the parsed JSON model
Expand All @@ -235,7 +237,7 @@ private void readRawLicenses(ApplicationComponent applicationComponent, JsonNode
String trace = rawLicenseNode.get("trace").asText(null);
boolean specialHandling = rawLicenseNode.get("specialHandling").asBoolean();

RawLicense rawLicense = modelFactory.newRawLicense();
RawLicense rawLicense = this.modelFactory.newRawLicense();
rawLicense.setApplicationComponent(applicationComponent);
rawLicense.setDeclaredLicense(declaredLicense);
rawLicense.setLicenseUrl(licenseUrl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ private void findCellsToIterate(Map<Cell, String> dataIterators, Workbook wb, Co

/**
* This function will fill in information in the template sheet.
*
*
* @param wb the workbook to work on
* @param cell the cell to start from
* @param dataTable the table which contains the data
Expand Down Expand Up @@ -208,9 +208,9 @@ public void writeReport(String templateSource, String target, Map<String, DataTa
// #Level.value# as
// content

try (InputStream inp = inputStreamFactory.createInputStreamFor(templateSource)) { // read
// the
// template
try (InputStream inp = this.inputStreamFactory.createInputStreamFor(templateSource)) { // read
// the
// template

Workbook wb = WorkbookFactory.create(inp);

Expand All @@ -233,6 +233,9 @@ public void writeReport(String templateSource, String target, Map<String, DataTa
iterateFromCell(wb, cell, dataTable, label);
}

// force reevaluation of all formulas
wb.setForceFormulaRecalculation(true);

// Write the output to a file
IOHelper.checkAndCreateLocation(target);
try (OutputStream fileOut = new FileOutputStream(target)) {
Expand Down

0 comments on commit 09dd107

Please sign in to comment.