Skip to content
Snippets Groups Projects
Commit 9b706727 authored by Ghislain Loas's avatar Ghislain Loas
Browse files

dev #35088 implementing post

parent 64399a33
6 merge requests!1659Master,!1622Dev#35088 oai import in cosmogramme,!1619Dev#35088 oai import in cosmogramme,!1611Dev#35088 oai import in cosmogramme,!1607Dev#40786 zendification de l ecran de parametrages des profils de donnees,!1606Dev#40786 zendification de l ecran de parametrages des profils de donnees
......@@ -391,11 +391,7 @@ class Cosmo_DataProfileControllerPostEditUnimarcKohaFileFormatTest extends Cosmo
2 => ''],
'nouveaute_valeurs' => ['nouveau',
'new'],
'subscribers' => 'ORDREABON; ORDREABON',
'loans' => 'ID_PERGAME; ID_PERGAME',
'holds' => 'SUPPORT; SUPPORT',
'light_records' => 'ean;ean',
'carts' => 'LIBELLE; ROLE'];
'subscribers' => 'ORDREABON; ORDREABON'];
$this->postDispatch('cosmo/data-profile/edit/id/56', $post, true);
......@@ -491,4 +487,55 @@ class Cosmo_DataProfileControllerPostEditUnimarcKohaFileFormatTest extends Cosmo
public function noveltyValeursShouldBeNouveauAndNew() {
$this->assertEquals('nouveau;new', $this->_koha->getNoveltyValues());
}
}
\ No newline at end of file
/** @test */
public function subscribersFieldsShouldContainsOrdreabon() {
$this->assertEquals('ORDREABON; ORDREABON', $this->_koha->getSubscriberFieldsValues());
}
}
class Cosmo_DataProfileControllerPostEditFieldsTest extends Cosmo_DataProfileControllerTestCase {
/** @test */
public function loansFieldsShouldContainsIdPergame() {
$this->postDispatch('cosmo/data-profile/edit/id/105', ['loans' => 'ID_PERGAME; ID_PERGAME'], true);
$this->assertEquals('ID_PERGAME; ID_PERGAME', Class_IntProfilDonnees::find(105)->getLoansFieldsValues());
}
/** @test */
public function lightRecordsFieldsShouldContainsEan() {
$this->postDispatch('cosmo/data-profile/edit/id/105', ['light_records' => 'ean;ean'], true);
$this->assertEquals('ean;ean', Class_IntProfilDonnees::find(105)->getLightRecordsFieldsValues());
}
/** @test */
public function holdsFieldsShouldContainsSupport() {
$this->postDispatch('cosmo/data-profile/edit/id/105', ['holds' => 'SUPPORT; SUPPORT'], true);
$this->assertEquals('SUPPORT; SUPPORT', Class_IntProfilDonnees::find(105)->getHoldsFieldsValues());
}
/** @test */
public function cartsFieldsShouldContainsLibelleAndRole() {
$this->postDispatch('cosmo/data-profile/edit/id/105', ['carts' => 'LIBELLE; ROLE'], true);
$this->assertEquals('LIBELLE; ROLE', Class_IntProfilDonnees::find(105)->getCartsFieldsValues());
}
/** @test */
public function docTypeFieldsShouldBeAsExpected() {
$doc_type = ['1_label' => ['am',
'af',
'bb'],
'1_zone' => ['z',
't',
'u']];
$this->postDispatch('cosmo/data-profile/edit/id/105', $doc_type, true);
$this->assertEquals(['code' => '1', 'label' => 'am;af;bb', 'zone_995' => 'z;t;u'], Class_IntProfilDonnees::find(105)->getItemDocTypesPrefs()[1]);
}
}
......@@ -774,6 +774,36 @@ class Class_IntProfilDonnees extends Storm_Model_Abstract {
}
public function getSubscriberFieldsValues() {
return $this->getProfilePrefs()->getSubscriberFields();
}
public function getLoansFieldsValues() {
return $this->getProfilePrefs()->getUnknownFields();
}
public function getLightRecordsFieldsValues() {
return $this->getProfilePrefs()->getUnknownFields();
}
public function getHoldsFieldsValues() {
return $this->getProfilePrefs()->getUnknownFields();
}
public function getCartsFieldsValues() {
return $this->getProfilePrefs()->getUnknownFields();
}
public function getItemDocTypesPrefs() {
return $this->getProfilePrefs()->getDocTypesPrefs();
}
public function getProfilePrefs() {
if(!$this->_profile_prefs)
$this->_profile_prefs = (new Class_ProfilePrefs())->setDatas($this->toArray());
......
......@@ -31,11 +31,9 @@ class Class_ProfileSerializer {
public function serializeDatas() {
$datas = [$this->extractRecords(),
$this->extractNovelty(),
$this->extractSubscribers(),
$this->extractCarts(),
$this->extractLoans(),
$this->extractHolds()];
$this->extractNovelty(),
$this->extractProfileFields(),
$this->extractSubscribers()];
return serialize($datas);
}
......@@ -47,7 +45,37 @@ class Class_ProfileSerializer {
public function extractDocTypes() {
return [Class_IntProfilDonnees::PROFILE_DOC_TYPES => []];
$doc_types_prefs = [];
$doc_types = Class_TypeDoc::findAll();
foreach($doc_types as $doc_type) {
$doc_type_id = $doc_type->getId();
$doc_types_prefs[$doc_type_id] = ['code' => $doc_type_id,
'label' => $this->_extractDocTypeLabel($doc_type_id),
'zone_995' => $this->_extractDocTypeZone($doc_type_id)];
}
return [Class_IntProfilDonnees::PROFILE_DOC_TYPES => $doc_types_prefs];
}
protected function _extractDocTypeLabel($id) {
return $this->_extractDocTypeData($id . '_label');
}
protected function _extractDocTypeZone($id) {
return $this->_extractDocTypeData($id . '_zone');
}
protected function _extractDocTypeData($key) {
if(!isset($this->_datas[$key]))
return '';
if(!is_array($this->_datas[$key]))
return '';
return implode(';', $this->_datas[$key]);
}
......@@ -62,11 +90,6 @@ class Class_ProfileSerializer {
}
public function extractInterestFields() {
}
public function extractNovelty() {
return [Class_IntProfilDonnees::PROFILE_NOVELTY => $this->_datas['nouveaute_jours'],
Class_IntProfilDonnees::NOVELTY_ZONE => $this->_datas['nouveaute_zone'][1],
......@@ -89,22 +112,18 @@ class Class_ProfileSerializer {
public function extractSubscribers() {
return [Class_IntProfilDonnees::XML_SUBSCRIBER_FIELD => $this->extractXmlSubscriber(),
Class_IntProfilDonnees::XML_SUBSCRIBER_FIELDS => $this->extractSubscriberFields()];
}
public function extractCarts() {
}
public function extractLoans() {
Class_IntProfilDonnees::XML_SUBSCRIBER_FIELDS => $this->extractSubscriberFields(),
Class_IntProfilDonnees::PROFILE_FIELDS => $this->_datas['subscribers']];
}
public function extractHolds() {
public function extractProfileFields() {
$fields = array_filter(array_intersect_key($this->_datas, ['loans' => '',
'holds' => '',
'light_records' => '',
'carts' => '']));
return [Class_IntProfilDonnees::PROFILE_FIELDS => array_shift($fields)];
}
......
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