Skip to content

Commit

Permalink
feat(export): Export Copyrights
Browse files Browse the repository at this point in the history
The page License List has been renamed to Export List.

The page can now export License List (as before) and Copyright List as
well. The Copyright List has a filter to export all copyrights or to
export copyrights from files which do not have license.

Files without license here refers to:
1. File had no license finding by agents and no license was added by
   users.
2. File had license findings by agents but were either removed or file
   was marked as irrelevant.

The ui-license-list-form.html.twig was renamed to
ui-export-list.html.twig as the template generates full response, not
just the form.

Signed-off-by: Gaurav Mishra <mishra.gaurav@siemens.com>
  • Loading branch information
GMishx committed Jun 11, 2020
1 parent d9f6f67 commit 462591e
Show file tree
Hide file tree
Showing 8 changed files with 817 additions and 375 deletions.
38 changes: 36 additions & 2 deletions src/lib/php/BusinessRules/ClearingDecisionFilter.php
@@ -1,6 +1,6 @@
<?php
/*
Copyright (C) 2014-2017, Siemens AG
Copyright (C) 2014-2017,2020, Siemens AG
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
Expand Down Expand Up @@ -135,4 +135,38 @@ public function getDecisionOf($decisionMap, $itemId, $pfileId)

return false;
}
}

/**
* @brief Get clearing decision as map of `<item-id> => <license-shortnames>`
* for copyright list
*
* Irrelevant decisions and removed licenses are marked as `"Void"`.
* @param ClearingDecision[] $clearingDecisions Clearing decisions to be
* filtered.
* @return ClearingDecision[]
*/
public function filterCurrentClearingDecisionsForCopyrightList($clearingDecisions)
{
$clearingDecisionsForCopyList = array();

foreach ($clearingDecisions as $clearingDecision) {
$itemId = $clearingDecision->getUploadTreeId();
$clearingDecisionsForCopyList[$itemId] = array();
if ($clearingDecision->getType() == DecisionTypes::IRRELEVANT) {
$clearingDecisionsForCopyList[$itemId][] = "Void";
continue;
}

foreach ($clearingDecision->getClearingLicenses() as $clearingLicense) {
if ($clearingLicense->isRemoved()) {
continue;
}
$clearingDecisionsForCopyList[$itemId][] = $clearingLicense->getShortName();
}
if (empty($clearingDecisionsForCopyList[$itemId])) {
$clearingDecisionsForCopyList[$itemId][] = "Void";
}
}
return $clearingDecisionsForCopyList;
}
}
18 changes: 13 additions & 5 deletions src/lib/php/Dao/CopyrightDao.php
Expand Up @@ -215,13 +215,15 @@ public function getScannerEntries($tableName, $uploadTreeTableName, $uploadId, $
}

/**
* @param $tableName
* @param $uploadTreeTableName
* @param $uploadId
* @param $decisionType
* @param string $tableName
* @param string $uploadTreeTableName
* @param integer $uploadId
* @param integer $decisionType
* @param string $extrawhere
* @return array $result
*/
public function getEditedEntries($tableName, $uploadTreeTableName, $uploadId, $decisionType)
public function getEditedEntries($tableName, $uploadTreeTableName, $uploadId,
$decisionType, $extrawhere="")
{
$statementName = __METHOD__.$tableName.$uploadTreeTableName;
$params = array();
Expand All @@ -238,6 +240,12 @@ public function getEditedEntries($tableName, $uploadTreeTableName, $uploadId, $d
$extendWClause .= " AND clearing_decision_type_fk = $".count($params);
$statementName .= ".withDecisionType";
}

if (!empty($extrawhere)) {
$extendWClause .= " AND ". $extrawhere;
$statementName .= "._".$extrawhere."_";
}

$columns = "CD.description as description, CD.textfinding as textfinding, CD.comment as comments, UT.uploadtree_pk as uploadtree_pk";

$primaryColumn = $tableName . '_pk';
Expand Down
3 changes: 2 additions & 1 deletion src/www/ui/Makefile
Expand Up @@ -27,7 +27,8 @@ UIFILES = `find . -type f | grep -v svn |grep -v tests | grep -E "(php|dat|dtd|j
OBSOLETEFILES = admin-tag-ns.php admin-change-owner.php admin-tag-ns-perm.php admin-folder-delete.php \
admin-dashboard.php ajax-showjobs.php group-manage-self.php group-manage.php ajax-perms.php \
upload_permissions.php upload-srv-files.php upload-vcs.php template/components \
template/include ui-browse-license.php
template/include ui-browse-license.php ui-license-list.php \
template/ui-license-list-form.html.twig

OTHERFILES = `find . -type f | grep -v svn |grep -v tests | grep -E "(css|htc|gif|png|ico|htm|openapi.yaml)$$"`

Expand Down
6 changes: 3 additions & 3 deletions src/www/ui/api/Helper/UploadHelper.php
Expand Up @@ -584,10 +584,10 @@ public function getUploadLicenseList($uploadId, $agents, $printContainers)
$scanProx->createAgentStatus($agents);
$agent_ids = $scanProx->getLatestSuccessfulAgentIds();

/** @var ui_license_list $licenseListObj
* ui_license_list object to get licenses
/** @var UIExportList $licenseListObj
* UIExportList object to get licenses
*/
$licenseListObj = $restHelper->getPlugin('license-list');
$licenseListObj = $restHelper->getPlugin('export-list');
$licenseList = $licenseListObj->createListOfLines($uploadTreeTableName,
$parent->getItemId(), $agent_ids, -1, true, '', !$printContainers);
if (array_key_exists("warn", $licenseList)) {
Expand Down
160 changes: 160 additions & 0 deletions src/www/ui/template/ui-export-list.html.twig
@@ -0,0 +1,160 @@
{# Copyright 2016-2017,2020 Siemens AG
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright notice and this notice are preserved.
This file is offered as-is, without any warranty.
#}
{% extends "include/base.html.twig" %}

{% block content %}
{{ parent() }}
<div id="exportList" style="padding-bottom:2em">
<ul>
<li><a href="#licenseList">License List</a></li>
<li><a href="#copyrightList">Copyright List</a></li>
</ul>
<div id="licenseList">
<form method='POST'>
<ol>
<li>
<span>
{{ "Which agents do you want to include?"|trans }}
</span>
<ul>
<li>
<label>
<input type="checkbox" name="agentToInclude_monk" value="yes" {% if agentToInclude_monk %}checked{% endif %}>
Monk
</label>
</li>
<li>
<label>
<input type="checkbox" name="agentToInclude_nomos" value="yes" {% if agentToInclude_nomos %}checked{% endif %}>
Nomos
</label>
</li>
<li>
<label>
<input type="checkbox" name="agentToInclude_ninka" value="yes" {% if agentToInclude_ninka %}checked{% endif %}>
Ninka
</label>
</li>
<li>
<label>
<input type="checkbox" name="agentToInclude_ojo" value="yes" {% if agentToInclude_ojo %}checked{% endif %}>
Ojo
</label>
</li>
<li>
<label>
<input type="checkbox" name="agentToInclude_reportImport" value="yes" {% if agentToInclude_reportImport %}checked{% endif %}>
Report Import
</label>
</li>
</ul>
</li>
<li>
<label>
<input type="checkbox" name="doNotIncludeSubfolder" value="yes" {% if not includeSubfolder %}checked{% endif %}>
Do not include subdirectories?
</label>
</li>
<li>
<label>
<input type="checkbox" name="showContainers" value="yes" {% if showContainers %}checked{% endif %}>
Show directories and containers?
</label>
</li>
<li>
<label>
Exclude:
<input name="exclude" value="{{ exclude|e }}">
<br/>
Exclude files containing some substring in the path. 'mac' and it should
exclude all files and directories containing the substring 'mac'.
</label>
</li>
<li>
<label>
<input type="checkbox" name="output" value="dltext" {% if dltext %}checked{% endif %}>
Download CSV after creation?
</label>
</li>
</ol>
<input type='submit' value='{{ "Generate list"|trans }}'>
</form>
</div>
<div id="copyrightList">
<form method='POST'>
<input type="hidden" name="export_copy" value="yes" />
<ol>
<li>
{{ "Which copyrights to export?"|trans }}
<ul>
<li>
<label>
<input type="radio" name="copyright_type" value="all" {% if copy_type_all %}checked{% endif %} />
{{ "All files"|trans }}
</label>
</li>
<li>
<label>
<input type="radio" name="copyright_type" value="nolic" {% if copy_type_nolic %}checked{% endif %} />
{{ "Files without licenses" }}
</label>
</ul>
</li>
<li>
<label>
Exclude:
<input name="exclude" value="{{ exclude|e }}">
<br/>
Exclude files containing some substring in the path. 'mac' and it should
exclude all files and directories containing the substring 'mac'.
</label>
</li>
<li>
<label>
<input type="checkbox" name="output" value="dltext" {% if dltext %}checked{% endif %}>
Download CSV after creation?
</label>
</li>
</ol>
<input type='submit' value='{{ "Generate list"|trans }}'>
</form>
</div>
</div>
<p>
With this tool you will only be able to obtain a list with at maximum
{{ NomostListNum }} entries.
For a full list run fo_nomos_license_list from the command line.
This Limit can be modified by the administrator.
</p>
<hr />
{% for warn in warnings %}
{{ warn }}
{% endfor %}
<pre>
{{ listoutput }}
</pre>
{% endblock %}
{% block foot %}
{{ parent() }}
<script src="scripts/jquery.cookie.js" type="text/javascript"></script>

<script type="text/javascript">
var exportCookie = 'stickyEmailTab';
$(document).ready(function() {
$("#exportList").tabs({
active: ($.cookie(exportCookie) || {% if export_copy %}1{% else %}0{% endif %}),
activate: function(e, ui){
// Get active tab index and update cookie
var idString = $(e.currentTarget).attr('id');
idString = parseInt(idString.slice(-1)) - 1;
$.cookie(exportCookie, idString);
}
});
});
</script>
{% endblock %}
67 changes: 0 additions & 67 deletions src/www/ui/template/ui-license-list-form.html.twig

This file was deleted.

0 comments on commit 462591e

Please sign in to comment.