Skip to content

Commit

Permalink
Merge pull request #1125 from siemens/contrib/inclusionOfLicTxtActCom…
Browse files Browse the repository at this point in the history
…InBulk

feat(bulk): inclusion of licensetext, acknowledgement and comment

review-by:anupam.ghosh@siemens.com
tested-by:anupam.ghosh@siemens.com
  • Loading branch information
mcjaeger committed Jul 10, 2018
2 parents 94bbad4 + de88249 commit 32b00a1
Show file tree
Hide file tree
Showing 16 changed files with 139 additions and 80 deletions.
4 changes: 2 additions & 2 deletions src/decider/agent/BulkReuser.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ public function rerunBulkAndDeciderOnUpload($uploadId, $groupId, $userId, $bulkI
$sql = "INSERT INTO license_ref_bulk (user_fk,group_fk,rf_text,upload_fk,uploadtree_fk) "
. "SELECT $1 AS user_fk, $2 AS group_fk,rf_text,$3 AS upload_fk, $4 as uploadtree_fk
FROM license_ref_bulk WHERE lrb_pk=$5 RETURNING lrb_pk, $5 as lrb_origin";
$sqlLic = "INSERT INTO license_set_bulk (lrb_fk,rf_fk,removing) "
."SELECT $1 as lrb_fk,rf_fk,removing FROM license_set_bulk WHERE lrb_fk=$2";
$sqlLic = "INSERT INTO license_set_bulk (lrb_fk, rf_fk, removing, comment, reportinfo, acknowledgement) "
."SELECT $1 as lrb_fk, rf_fk, removing, comment, reportinfo, acknowledgement FROM license_set_bulk WHERE lrb_fk=$2";
$this->dbManager->prepare($stmt=__METHOD__.'cloneBulk', $sql);
$this->dbManager->prepare($stmtLic=__METHOD__.'cloneBulkLic', $sqlLic);
$res = $this->dbManager->execute($stmt,array($userId,$groupId,$uploadId,$topItem, $bulkId));
Expand Down
6 changes: 3 additions & 3 deletions src/lib/php/Dao/LicenseDao.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/*
Copyright (C) 2014-2017, Siemens AG
Copyright (C) 2014-2018, Siemens AG
Author: Andreas Würl
This program is free software; you can redistribute it and/or
Expand Down Expand Up @@ -610,10 +610,10 @@ public function insertBulkLicense($userId, $groupId, $uploadTreeId, $licenseRemo
$bulkId = $licenseRefBulkIdResult['lrb_pk'];

$stmt = __METHOD__ . '.insertAction';
$this->dbManager->prepare($stmt, "INSERT INTO license_set_bulk (lrb_fk, rf_fk, removing) VALUES ($1,$2,$3)");
$this->dbManager->prepare($stmt, "INSERT INTO license_set_bulk (lrb_fk, rf_fk, removing, comment, reportinfo, acknowledgement) VALUES ($1,$2,$3,$4,$5,$6)");
foreach($licenseRemovals as $licenseId=>$removing)
{
$this->dbManager->execute($stmt, array($bulkId, $licenseId, $this->dbManager->booleanToDb($removing)));
$this->dbManager->execute($stmt, array($bulkId, $licenseId, $this->dbManager->booleanToDb($removing[0]), $removing[1], $removing[2], $removing[3]));
}
return $bulkId ;
Expand Down
18 changes: 12 additions & 6 deletions src/monk/agent/monkbulk.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Author: Daniele Fognini, Andreas Wuerl
Copyright (C) 2013-2015, Siemens AG
Copyright (C) 2013-2015,2018 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 @@ -129,7 +129,7 @@ BulkAction** queryBulkActions(MonkState* state, long bulkId) {
fo_dbManager_PrepareStamement(
state->dbManager,
"queryBulkActions",
"SELECT rf_fk, removing FROM license_set_bulk WHERE lrb_fk = $1",
"SELECT rf_fk, removing, comment, reportinfo, acknowledgement FROM license_set_bulk WHERE lrb_fk = $1",
long
),
bulkId
Expand All @@ -144,6 +144,9 @@ BulkAction** queryBulkActions(MonkState* state, long bulkId) {
BulkAction *action = (BulkAction *) malloc(sizeof(BulkAction));
action->licenseId = atoi(PQgetvalue(bulkActionsResult, row, column++));
action->removing = (strcmp(PQgetvalue(bulkActionsResult, row, column++), "t") == 0);
action->comment = g_strdup(PQgetvalue(bulkActionsResult, row, column++));
action->reportinfo = g_strdup(PQgetvalue(bulkActionsResult, row, column++));
action->acknowledgement = g_strdup(PQgetvalue(bulkActionsResult, row, column++));
bulkActions[row] = action;
}
bulkActions[row] = NULL;
Expand Down Expand Up @@ -301,12 +304,12 @@ int bulk_onAllMatches(MonkState* state, const File* file, const GArray* matches)
fo_dbManager_PrepareStamement(
state->dbManager,
"saveBulkResult:decision",
"INSERT INTO clearing_event(uploadtree_fk, user_fk, group_fk, job_fk, type_fk, rf_fk, removed)"
" SELECT uploadtree_pk, $2, $3, $4, $5, $6, $7"
"INSERT INTO clearing_event(uploadtree_fk, user_fk, group_fk, job_fk, type_fk, rf_fk, removed, comment, reportinfo, acknowledgement)"
" SELECT uploadtree_pk, $2, $3, $4, $5, $6, $7, $8, $9, $10"
" FROM uploadtree"
" WHERE upload_fk = $8 AND pfile_fk = $1 AND lft BETWEEN $9 AND $10"
" WHERE upload_fk = $11 AND pfile_fk = $1 AND lft BETWEEN $12 AND $13"
"RETURNING clearing_event_pk",
long, int, int, int, int, long, int,
long, int, int, int, int, long, int, char*, char*, char*,
int, long, long
),
file->id,
Expand All @@ -317,6 +320,9 @@ int bulk_onAllMatches(MonkState* state, const File* file, const GArray* matches)
BULK_DECISION_TYPE,
action->licenseId,
action->removing ? 1 : 0,
action->comment,
action->reportinfo,
action->acknowledgement,

bulkArguments->uploadId,
bulkArguments->uploadTreeLeft,
Expand Down
5 changes: 4 additions & 1 deletion src/monk/agent/monkbulk.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Author: Daniele Fognini, Andreas Wuerl
Copyright (C) 2013-2014, Siemens AG
Copyright (C) 2013-2014,2018 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 @@ -32,6 +32,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
typedef struct {
long licenseId;
int removing;
char* comment;
char* reportinfo;
char* acknowledgement;
} BulkAction;

typedef struct {
Expand Down
2 changes: 1 addition & 1 deletion src/readmeoss/agent/readmeoss.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ private function createReadMeOSSFormat($addSeparator, $dataForReadME, $extract='
if($extract == 'text') {
$outData .= $statements["content"] . $break;
}
$outData .= $statements[$extract] . $break;
$outData .= str_replace("\n", "\r\n", $statements[$extract]) . $break;
if(!empty($addSeparator)) {
$outData .= $addSeparator . $break;
}
Expand Down
6 changes: 3 additions & 3 deletions src/unifiedreport/agent/unifiedreport.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ private function globalLicenseTable(Section $section, $mainLicenses, $titleSubHe
$cell1->addText(htmlspecialchars($licenseMain["content"], ENT_DISALLOWED), $this->licenseColumn, "pStyle");
$cell2 = $table->addCell($secondColLen);
// replace new line character
$licenseText = str_replace("\n", "<w:br/>", htmlspecialchars($licenseMain["text"], ENT_DISALLOWED));
$licenseText = str_replace("\n", "<w:br/>\n", htmlspecialchars($licenseMain["text"], ENT_DISALLOWED));
$cell2->addText($licenseText, $this->licenseTextColumn, "pStyle");
if(!empty($licenseMain["files"])){
$cell3 = $table->addCell($thirdColLen, $styleColumn);
Expand Down Expand Up @@ -352,7 +352,7 @@ private function bulkLicenseTable(Section $section, $title, $licenses, $titleSub
$cell1->addText(htmlspecialchars($licenseStatement["content"], ENT_DISALLOWED), $this->licenseColumn, "pStyle");
$cell2 = $table->addCell($secondColLen, "pStyle");
// replace new line character
$licenseText = str_replace("\n", "<w:br/>", htmlspecialchars($licenseStatement["text"], ENT_DISALLOWED));
$licenseText = str_replace("\n", "<w:br/>\n", htmlspecialchars($licenseStatement["text"], ENT_DISALLOWED));
$cell2->addText($licenseText, $this->licenseTextColumn, "pStyle");
$cell3 = $table->addCell($thirdColLen, null, "pStyle");
asort($licenseStatement["files"]);
Expand Down Expand Up @@ -396,7 +396,7 @@ private function licensesTable(Section $section, $title, $licenses, $riskarray,
$cell1->addText(htmlspecialchars($licenseStatement["content"], ENT_DISALLOWED), $this->licenseColumn, "pStyle");
$cell2 = $table->addCell($secondColLen);
// replace new line character
$licenseText = str_replace("\n", "<w:br/>", htmlspecialchars($licenseStatement["text"], ENT_DISALLOWED));
$licenseText = str_replace("\n", "<w:br/>\n", htmlspecialchars($licenseStatement["text"], ENT_DISALLOWED));
$cell2->addText($licenseText, $this->licenseTextColumn, "pStyle");
$cell3 = $table->addCell($thirdColLen, $riskarray['color']);
asort($licenseStatement["files"]);
Expand Down
5 changes: 3 additions & 2 deletions src/www/ui/change-license-bulk.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/***********************************************************
* Copyright (C) 2014-2015 Siemens AG
* Copyright (C) 2014-2015,2018 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 @@ -112,10 +112,11 @@ private function getJobQueueId($uploadTreeId, Request $request)

$refText = $request->get('refText');
$actions = $request->get('bulkAction');

$licenseRemovals = array();
foreach($actions as $licenseAction)
{
$licenseRemovals[$licenseAction['licenseId']] = ($licenseAction['action']=='remove');
$licenseRemovals[$licenseAction['licenseId']] = array(($licenseAction['action']=='Remove'), $licenseAction['comment'], $licenseAction['reportinfo'], $licenseAction['acknowledgement']);
}
$bulkId = $this->licenseDao->insertBulkLicense($userId, $groupId, $uploadTreeId, $licenseRemovals, $refText);

Expand Down
12 changes: 12 additions & 0 deletions src/www/ui/core-schema.dat
Original file line number Diff line number Diff line change
Expand Up @@ -970,6 +970,18 @@
$Schema["TABLE"]["license_set_bulk"]["lrb_fk"]["ADD"] = "ALTER TABLE \"license_set_bulk\" ADD COLUMN \"lrb_fk\" int8";
$Schema["TABLE"]["license_set_bulk"]["lrb_fk"]["ALTER"] = "ALTER TABLE \"license_set_bulk\" ALTER COLUMN \"lrb_fk\" SET NOT NULL";

$Schema["TABLE"]["license_set_bulk"]["comment"]["DESC"] = "COMMENT ON COLUMN \"license_set_bulk\".\"comment\" IS 'User comment'";
$Schema["TABLE"]["license_set_bulk"]["comment"]["ADD"] = "ALTER TABLE \"license_set_bulk\" ADD COLUMN \"comment\" text";
$Schema["TABLE"]["license_set_bulk"]["comment"]["ALTER"] = "ALTER TABLE \"license_set_bulk\" ALTER COLUMN \"comment\" DROP NOT NULL";

$Schema["TABLE"]["license_set_bulk"]["reportinfo"]["DESC"] = "COMMENT ON COLUMN \"license_set_bulk\".\"reportinfo\" IS 'public comment'";
$Schema["TABLE"]["license_set_bulk"]["reportinfo"]["ADD"] = "ALTER TABLE \"license_set_bulk\" ADD COLUMN \"reportinfo\" text";
$Schema["TABLE"]["license_set_bulk"]["reportinfo"]["ALTER"] = "ALTER TABLE \"license_set_bulk\" ALTER COLUMN \"reportinfo\" DROP NOT NULL";

$Schema["TABLE"]["license_set_bulk"]["acknowledgement"]["DESC"] = "COMMENT ON COLUMN \"license_set_bulk\".\"acknowledgement\" IS 'public comment'";
$Schema["TABLE"]["license_set_bulk"]["acknowledgement"]["ADD"] = "ALTER TABLE \"license_set_bulk\" ADD COLUMN \"acknowledgement\" text";
$Schema["TABLE"]["license_set_bulk"]["acknowledgement"]["ALTER"] = "ALTER TABLE \"license_set_bulk\" ALTER COLUMN \"acknowledgement\" DROP NOT NULL";


$Schema["TABLE"]["mimetype"]["mimetype_pk"]["DESC"] = "";
$Schema["TABLE"]["mimetype"]["mimetype_pk"]["ADD"] = "ALTER TABLE \"mimetype\" ADD COLUMN \"mimetype_pk\" int4 DEFAULT nextval('mimetype_mimetype_pk_seq'::regclass)";
Expand Down
4 changes: 2 additions & 2 deletions src/www/ui/scripts/change-license-browse.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2014-2017, Siemens AG
Copyright (C) 2014-2018, Siemens AG
Author: Daniele Fognini, Johannes Najjar
This program is free software; you can redistribute it and/or
Expand All @@ -25,7 +25,7 @@ var userModal;
var removed = false;

$(document).ready(function () {
bulkModal = $('#bulkModal').plainModal();
bulkModal = $('#bulkModal').plainModal({child: textModal});
userModal = $('#userModal').plainModal();
clearingHistoryDataModal = $('#ClearingHistoryDataModal').plainModal();
});
Expand Down
70 changes: 69 additions & 1 deletion src/www/ui/scripts/change-license-common.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2014-2017, Siemens AG
Copyright (C) 2014-2018, Siemens AG
Author: Daniele Fognini, Johannes Najjar, Steffen Weber
This program is free software; you can redistribute it and/or
Expand Down Expand Up @@ -130,6 +130,12 @@ function isUserError(bulkActions, refText) {
function scheduleBulkScanCommon(resultEntity, callbackSuccess) {
var bulkActions = getBulkFormTableContent();
var refText = $('#bulkRefText').val();
var i;
for (i = 0; i < bulkActions.length; i++) {
bulkActions[i]["reportinfo"] = $("#"+bulkActions[i].licenseId+"reportinfoBulk").attr('title');
bulkActions[i]["acknowledgement"] = $("#"+bulkActions[i].licenseId+"acknowledgementBulk").attr('title');
bulkActions[i]["comment"] = $("#"+bulkActions[i].licenseId+"commentBulk").attr('title');
}

//checks for user errors
if(isUserError(bulkActions, refText)) {
Expand Down Expand Up @@ -224,3 +230,65 @@ function removeMainLicense(uploadId,licenseId) {
.fail(failed);
}
}
function openTextModel(uploadTreeId, licenseId, what, type) {
if(type === undefined) {
type = 0;
}
if(type == 0) {
clearingsForSingleFile = $("#clearingsForSingleFile"+licenseId+what).attr("title");
idLicUploadTree = uploadTreeId+','+licenseId;
whatCol = what;
$("#referenceText").val(clearingsForSingleFile);
textModal.plainModal('open');
} else {
$("#referenceText").val($("#"+licenseId+what+type).attr('title'));
whatCol = what;
whatLicId = licenseId;
textModal.plainModal('open');
}
whatType = type;
}

function closeTextModal() {
textModal.plainModal('close');
}

function submitTextModal(){
if(whatType == 0) {
var post_data = {
"id": idLicUploadTree,
"columnId": whatCol,
"value": $("#referenceText").val()
};
$.ajax({
type: "POST",
url: "?mod=conclude-license&do=updateClearings",
data: post_data,
success: doOnSuccess
});
} else {
textModal.plainModal('close');
$("#"+ whatLicId + whatCol +"Bulk").attr('title', $("#referenceText").val());
referenceText = $("#referenceText").val().trim();
if(referenceText !== null && referenceText !== '') {
$("#"+ whatLicId + whatCol + whatType).html($("#"+ whatLicId + whatCol + whatType).attr('title').slice(0, 10) + "...");
} else {
$("#"+ whatLicId + whatCol +"Bulk").attr('title','');
}
}
}

function doOnSuccess() {
textModal.plainModal('close');
$('#decTypeSet').addClass('decTypeWip');
oTable = $('#licenseDecisionsTable').dataTable(selectedLicensesTableConfig).makeEditable(editableConfiguration);
oTable.fnDraw(false);
}
$(document).ready(function () {
textModal = $('#textModal').plainModal();
$('#textModal').draggable({
stop: function(){
$(this).css({'width':'','height':''});
}
});
});
2 changes: 1 addition & 1 deletion src/www/ui/scripts/change-license-view.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2014-2017, Siemens AG
Copyright (C) 2014-2018, Siemens AG
Author: Daniele Fognini, Johannes Najjar
This program is free software; you can redistribute it and/or
Expand Down
Loading

0 comments on commit 32b00a1

Please sign in to comment.