Commit 2e797382 authored by Alexandre Morin's avatar Alexandre Morin
Browse files

Merge branch 'hotfix/2.1.1' into 'master'

Hotfix/2.1.1

See merge request maarch/thirdPartyArchiving!13
parents 6ae9dba9 dca80c62
......@@ -333,11 +333,8 @@ class ArchiveRestitutionRequest extends abstractMessage
$messages = $this->sdoFactory->find("medona/message", "status='accepted' AND type='ArchiveRestitutionRequest' AND active=true");
foreach ($messages as $message) {
$this->changeStatus($message->messageId, "processing");
$this->loadData($message);
try {
$results[(string) $message->messageId] = $this->process($message);
$results[(string) $message->messageId] = $this->process((string)$message->messageId);
} catch (\Exception $e) {
$results[(string) $message->messageId] = $e;
}
......
......@@ -82,9 +82,13 @@ class controlAuthority
*/
public function update($controlAuthority, $originatorOrgUnitId)
{
$this->delete($originatorOrgUnitId);
$this->create($controlAuthority);
if(($controlAuthority->originatorOrgUnitId=='*')||empty($this->sdoFactory->find('medona/controlAuthority',"originatorOrgUnitId='$controlAuthority->originatorOrgUnitId'" ))) {
$this->delete($originatorOrgUnitId);
$this->create($controlAuthority);
} else {
throw \laabs::Bundle('medona')->newException('controlAuthorityException', 'The relation control authority and orignator already exists.');
}
return true;
}
......
......@@ -260,9 +260,10 @@ class message
*/
public function search($type, $reference = null, $archiver = null, $originator = null, $depositor = null, $archivalAgreement = null, $fromDate = null, $toDate = null, $isIncoming = null)
{
$queryParts = $this->searchMessage($type, $reference, $archiver, $originator, $depositor, $archivalAgreement, $fromDate, $toDate, $isIncoming);
$queryParams = array();
$queryString = $this->searchMessage($type, $reference, $archiver, $originator, $depositor, $archivalAgreement, $fromDate, $toDate, $isIncoming,$queryParams);
return $this->sdoFactory->find('medona/message', '('.implode(') and (', $queryParts).')', null, false, false, 300);
return $this->sdoFactory->find('medona/message', $queryString, $queryParams, false, false, 300);
}
/**
......@@ -278,7 +279,7 @@ class message
*
* @return medona/message[]
*/
public function searchMessage($type, $reference = null, $archiver = null, $originator = null, $depositor = null, $archivalAgreement = null, $fromDate = null, $toDate = null, $isIncoming = null)
public function searchMessage($type, $reference = null, $archiver = null, $originator = null, $depositor = null, $archivalAgreement = null, $fromDate = null, $toDate = null, $isIncoming = null,&$queryParams)
{
$queryParts = array();
$currentService = \laabs::getToken("ORGANIZATION");
......@@ -288,20 +289,21 @@ class message
$isArchiver = in_array('archiver', $currentService->orgRoleCodes);
$isControlAuthority = in_array('controlAuthority', $currentService->orgRoleCodes);
//if (!is_array($currentService->orgRoleCodes) || empty($currentService->orgRoleCodes)) {
// return array();
//}
if ($archiver || $originator || $depositor) {
$query = [];
if ($archiver) {
$query[] = "(senderOrgRegNumber='$archiver' OR recipientOrgRegNumber='$archiver')";
$query[] = "(senderOrgRegNumber= :archiver OR recipientOrgRegNumber= :archiver)";
$queryParams['archiver'] = $archiver;
}
if ($originator) {
$query[] = "(senderOrgRegNumber='$originator' OR recipientOrgRegNumber='$originator')";
$query[] = "(senderOrgRegNumber= :originator OR recipientOrgRegNumber= :originator)";
$queryParams['originator'] = $originator;
}
if ($depositor) {
$query[] = "(senderOrgRegNumber='$depositor' OR recipientOrgRegNumber='$depositor')";
$query[] = "(senderOrgRegNumber= :depositor OR recipientOrgRegNumber= :depositor)";
$queryParams['depositor'] = $depositor;
}
$size = sizeof($query);
......@@ -314,25 +316,29 @@ class message
}
}
if ($archivalAgreement) {
$queryParts[] = "archivalAgreementReference='$archivalAgreement'";
$queryParts[] = "archivalAgreementReference= :archivalAgreementReference";
$queryParams['archivalAgreementReference'] = $archivalAgreement;
}
if ($fromDate) {
$fromDate = \laabs::newDate($fromDate, "Y-m-d H:i:s");
$queryParts[] = "date >='$fromDate'";
$queryParts[] = "date >= :fromDate";
$queryParams['fromDate'] = $fromDate;
}
if ($toDate) {
$toDate = \laabs::newDate($toDate, "Y-m-d H:i:s");
$toDate->add(new \DateInterval("PT23H59M59S"));
$queryParts[] = "date <='$toDate'";
$queryParts[] = "date <= :toDate";
$queryParams['toDate'] = $toDate;
}
if ($reference) {
$queryParts[] = "reference='$reference'";
$queryParts[] = "reference= :reference";
$queryParams['reference'] = $reference;
}
if ($isIncoming !== null) {
switch ($isIncoming) {
case true :
$queryParts[] = "isIncoming= true";
break;
break;
case false :
$queryParts[] = "isIncoming= false";
break;
......@@ -351,7 +357,7 @@ class message
}
break;
case "ArchiveDestruction":
case "ArchiveDestruction":
if ($isArchiver) {
$clause[] = "type='*$type*'";
}
......@@ -368,7 +374,7 @@ class message
}
break;
case "ArchiveRestitution":
$clause[] = "type=['ArchiveRestitutionRequest','ArchiveRestitution']";
break;
......@@ -376,26 +382,26 @@ class message
case "ArchiveNotification":
$clause[] = "type=['ArchiveModificationNotification','ArchiveDestructionNotification','ArchivalProfileModificationNotification']";
break;
default :
$clause[] = "type='$type' AND status !='template'";
$clause[] = "type= :type AND status !='template'";
$queryParams['type'] = $type;
break;
}
if (!empty($clause)) {
$queryParts[] =
$queryParts[] =
'('
.\laabs\implode(') OR (', $clause)
.\laabs\implode(') OR (', $clause)
.')';
}
}
}
$orgUnitsClause = $this->getCurrentRegistrationNumber();
$currentServiceOrgRegNumber = $currentService->registrationNumber;
$queryParts[] = "(recipientOrgRegNumber= :currentServiceOrgRegNumber OR senderOrgRegNumber= :currentServiceOrgRegNumber)";
$queryParams['currentServiceOrgRegNumber'] = $currentServiceOrgRegNumber;
$queryParts[] = "(recipientOrgRegNumber='$currentServiceOrgRegNumber' OR senderOrgRegNumber='$currentServiceOrgRegNumber')";
return $queryParts;
return '('.implode(') and (', $queryParts).')';
}
/**
......@@ -1076,9 +1082,11 @@ class message
*/
public function getByReference($reference)
{
$queryParts = $this->searchMessage(null, $reference);
// $queryParts = $this->searchMessage(null, $reference);
$queryParams = array();
$queryString = $this->searchMessage(null, $reference, null, null, null, null, null, null, null,$queryParams);
$message = $this->sdoFactory->find('medona/message', '('.implode(') and (', $queryParts).')', null, false, false, 300);
$message = $this->sdoFactory->find('medona/message', $queryString, $queryParams, false, false, 300);
if (!$message) {
return null;
......
......@@ -282,6 +282,7 @@
<span class='hide' id="fullTextIndexation_txt">Full text indexation</span>
<span class='hide' id="mediaInfo_txt">Media info</span>
<span class='hide' id="noFormatFound">No format found</span>
</form>
</div>
</div>
......@@ -316,17 +317,20 @@
});
});
}
var typesSource = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('puid'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
remote: {
wildcard: '%QUERY',
url: '/digitalResource/format/find/%QUERY',
rateLimitWait: 500
rateLimitWait: 500,
transform: function(response) {
return response;
}
},
limit: 100
});
typesSource.initialize();
// initialize typeahead
$('#formatTypeahead').typeahead(
......@@ -338,36 +342,24 @@
// data source contacts
{
name: 'format',
displayKey: 'name',
templates: {
empty: function () {
return "<span class='well well-sm'>No format found</span>";
return "<span class='well well-sm'>" + $('#noFormatFound').text() + "</span>";
},
suggestion: function (type) {
var displayName = '[' + type['puid'] + '] ' + type['name'];
if (type['version'] != undefined) {
displayName += ' ' + type['version'];
var displayName = '[' + type.puid + '] ' + type.name;
if (type.version != undefined) {
displayName += ' ' + type.version;
}
var display = "<span>"
+ "<span style='font-family:Helvetica, sans-serif;'>"
+ displayName
+ "</span>"
+ "</span>";
+ "</span></span><br>";
return display;
}
},
source: function (query, cb) {
typesSource.get(query, function (suggestions) {
var i = suggestions.length
while (i--) {
if ($.inArray(suggestions[i].puid, boundFormats()) > -1)
suggestions.splice(i, 1);
}
cb(suggestions);
});
},
skipCache: true
display: 'name',
source: typesSource
}).on('typeahead:selected', function ($event, suggestion, source) {
$("#formatTypeahead").data('format', suggestion);
$('#addFormat').removeClass('disabled');
......@@ -468,7 +460,6 @@
//$("#table-clusterName").text(clusterName);
$.each(serviceControls, function (index, element) {
console.log(element);
var li = $('<li/>').addClass('list-group-item').text($("#"+ element + "_txt").text());
var i = $('<i/>').addClass('fa fa-check text-success pull-right').appendTo(li);
......
......@@ -14,7 +14,7 @@
<input name="controlAuthorityId" hidden="hidden">
<div class="form-group">
<label class="control-label col-sm-4">Control authority <span style="color : red">*</span></label>
<div class="col-sm-7">
<div class="col-sm-8">
<select class="form-control" name="controlAuthorityOrgUnitId">
<option value="">Select a control authority</option>
<?merge ownerControlAuthorityOrgs ?>
......@@ -25,9 +25,15 @@
</select>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-4">Default control authority</label>
<div class="col-sm-8">
<input type="checkbox" id="defaultOriginator" data-toggle="toggle"/>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-4">Service <span style="color : red">*</span></label>
<div class="col-sm-6">
<div class="col-sm-8">
<input type="text" class="form-control orgHide" placeholder="Originator" name="orgTypeahead" id="orgTypeahead"/>
<select class="form-control hide" name="originatorOrgUnitId" id="originatorOwnerOrgId">
<option value="">All</option>
......@@ -49,14 +55,14 @@
</div>
<div class="form-group" name="originatorOrgInfo">
<label class="control-label col-sm-4">Organization</label>
<div class="col-sm-6">
<span class="col-sm-6 align-middle" id="organizationOwnerOrgName"></span>
<div class="col-sm-8">
<span class="align-middle" id="organizationOwnerOrgName"></span>
</div>
</div>
<div class="form-group" name="originatorOrgInfo">
<label class="control-label col-sm-4">Service</label>
<div class="col-sm-6">
<span class="col-sm-6 align-middle" id="originatorOwnerOrgName"></span>
<div class="col-sm-8">
<span class="align-middle" id="originatorOwnerOrgName"></span>
</div>
</div>
......@@ -77,6 +83,18 @@
clearForm();
});
$('#defaultOriginator').change(function() {
if($(this).prop('checked')){
$("#orgTypeahead").prop('disabled', true);
} else {
$("#orgTypeahead").prop('disabled', false).val('');
$("#originatorOrgUnitId").val('');
$("#organizationOwnerOrgName").text('');
$("#originatorOwnerOrgName").text('');
}
})
$('#controlAuthority_save').on('click', function() {
var type = "POST";
var url = "/controlAuthority";
......@@ -125,7 +143,7 @@
controlAuthority = {
//keyword : []
};
$('#controlAuthority_Form').find('select').each(function(){
var name = $(this).attr('name');
var value = $(this).val();
......@@ -134,6 +152,10 @@
}
});
if($('#defaultOriginator').is(':checked')){
controlAuthority['originatorOrgUnitId'] = '*';
}
return controlAuthority;
}
......@@ -141,10 +163,19 @@
$('#controlAuthority_Form').css('display', '');
$("#organizationOwnerOrgName").html('');
$("#originatorOwnerOrgName").html('');
$("#orgTypeahead").val('');
$('#defaultOriginator').bootstrapToggle('off');
}
function loadControlAuthorityForm(controlAuthority, originator) {
var form = $('#controlAuthority_Form');
$('#organizationOwnerOrgName').text('');
if(originator=='*'){
$('#defaultOriginator').bootstrapToggle('on');
} else {
$('#defaultOriginator').bootstrapToggle('off');
}
form.find('[name="controlAuthorityId"]').html(originator);
form.find('select[name="controlAuthorityOrgUnitId"]').val(controlAuthority);
......@@ -194,7 +225,7 @@
displayKey: 'displayName',
templates: {
empty: function() {
return "<span class='well well-sm'>"+$('#noOriginatorFound').html()+"</span>";
return "<span class='well well-sm'>"+$('#noOriginatorFound').text()+"</span>";
},
suggestion: function(organization) {
var display =
......@@ -206,14 +237,13 @@
+ " > ";
}
display += organization.displayName
+ "</span>"
+ "</span>";
+ "</span></span><br>";
return display;
}
},
source: function(query, cb) {
organizations.get(query, function(suggestions) {
organizations.search(query, function(suggestions) {
var i = suggestions.length
while (i--) {
if ($('#orgs').find('[data-orgid="'+ suggestions[i].orgId +'"]').length)
......@@ -248,4 +278,5 @@
});
}
});
</script>
\ No newline at end of file
</script>
<script src="/public/js/bootstrap-toggle/bootstrap-toggle.js"></script>
......@@ -69,6 +69,7 @@
});
$('#controlAuthority_list').on('click', '.controlAuthorityModify', function() {
$('#orgTypeahead').val('');
var tr = $(this).closest("tr");
var controlAuthority = tr.data('controlauthority');
......
......@@ -71,8 +71,8 @@
} else {
filename = filename.substr(0, filename.lastIndexOf('.')) || filename;
}
window.open("/medona/message/" + messageId + "/attachment/" + $(this).data('id') + "/" + filename.replace(/ /g, "_"));
var regEx = new RegExp('[ .]', 'gi');
window.open("/medona/message/" + messageId + "/attachment/" + $(this).data('id') + "/" + filename.replace(regEx, "_"));
})
$('#messageModal').on('click','.showResource', function() {
......
......@@ -200,7 +200,6 @@
})
serializedObject['reference'] = reference;
console.log(serializedObject);
return serializedObject;
},
......
......@@ -113,11 +113,5 @@ interface messageInterface
*/
public function updateMedonaMessage_messageId_Retry();
/**
* Search message by sender / recipient / reference / date
*
* @uses medona/message/readSearch
* @return medona/message/historyList
*/
public function readHistories();
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment