Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
* develop:
  Fix ConceptScheme rdf type typo. refs #26937
  Fix a bug where 2 searches were performed on enter.
  Completely remove notation on creation for some tenants. It will be generated automatically. refs #27237
  • Loading branch information
dthornley committed Jul 6, 2016
2 parents 5075a7b + 39d7493 commit 53b9685
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 21 deletions.
20 changes: 11 additions & 9 deletions application/editor/forms/Concept.php
Expand Up @@ -150,17 +150,19 @@ protected function buildHeader()
//@TODO Add a param for this and for languages.
//Don't access the config directly
$editorOptions = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getOption('editor');
$allowNotationEdit = $this->getIsCreate() || (bool)$editorOptions['allowNotationEdit'];
$allowNotationEdit = (bool)$editorOptions['allowNotationEdit'];

$this->buildMultiElements(
[
'notation' => [
'label' => _('Notations:'),
'readonly' => !$allowNotationEdit,
if (!$this->getIsCreate()) {
$this->buildMultiElements(
[
'notation' => [
'label' => _('Notations:'),
'readonly' => !$allowNotationEdit,
],
],
],
'OpenSKOS_Form_Element_Multitextnolang'
);
'OpenSKOS_Form_Element_Multitextnolang'
);
}

if (!$this->_isCreate) {
$this->addElement('submit', 'conceptSave', array(
Expand Down
12 changes: 7 additions & 5 deletions library/OpenSkos2/Bridge/EasyRdf.php
Expand Up @@ -26,6 +26,8 @@
use OpenSkos2\SkosXl\LabelCollection;
use OpenSkos2\Concept;
use OpenSkos2\ConceptCollection;
use OpenSkos2\ConceptScheme;
use OpenSkos2\ConceptSchemeCollection;
use OpenSkos2\Person;
use OpenSkos2\Exception\InvalidArgumentException;
use OpenSkos2\Rdf\Literal;
Expand All @@ -47,7 +49,7 @@ public static function graphToResourceCollection(Graph $graph, $expectedType = n
foreach ($graph->resources() as $resource) {
/** @var $resource \EasyRdf\Resource */
$type = $resource->get('rdf:type');

// Filter out resources which are not fully described.
if (!$type) {
continue;
Expand Down Expand Up @@ -120,8 +122,8 @@ protected static function createResource($uri, $type)
switch ($type->getUri()) {
case Concept::TYPE:
return new Concept($uri);
case \OpenSkos2\ConceptScheme::TYPE:
return new \OpenSkos2\ConceptScheme($uri);
case ConceptScheme::TYPE:
return new ConceptScheme($uri);
case Collection::TYPE:
return new Collection($uri);
case Person::TYPE:
Expand All @@ -147,8 +149,8 @@ public static function createResourceCollection($type)
switch ($type) {
case Concept::TYPE:
return new ConceptCollection();
case \OpenSkos2\ConceptScheme::TYPE:
return new \OpenSkos2\ConceptSchemeCollection();
case ConceptScheme::TYPE:
return new ConceptSchemeCollection();
case Collection::TYPE:
return new CollectionCollection();
case Label::TYPE:
Expand Down
3 changes: 2 additions & 1 deletion library/OpenSkos2/ConceptScheme.php
Expand Up @@ -24,13 +24,14 @@
use OpenSkos2\Namespaces\OpenSkos;
use OpenSkos2\Rdf\Uri;
use OpenSkos2\Rdf\Literal;
use OpenSkos2\Namespaces\Dc;
use OpenSkos2\Namespaces\DcTerms;
use OpenSKOS_Db_Table_Tenants;
use Rhumsaa\Uuid\Uuid;

class ConceptScheme extends Resource
{
const TYPE = 'http://www.w3.org/2004/02/skos/core#conceptScheme';
const TYPE = 'http://www.w3.org/2004/02/skos/core#ConceptScheme';

/**
* Resource constructor.
Expand Down
15 changes: 10 additions & 5 deletions library/OpenSkos2/Import/Command.php
Expand Up @@ -20,6 +20,7 @@
namespace OpenSkos2\Import;

use OpenSkos2\Concept;
use OpenSkos2\ConceptScheme;
use OpenSkos2\Exception\ResourceNotFoundException;
use OpenSkos2\Converter\File;
use OpenSkos2\Namespaces\DcTerms;
Expand Down Expand Up @@ -72,10 +73,6 @@ public function handle(Message $message)
$file = new File($message->getFile());
$resourceCollection = $file->getResources();

// @TODO Most of the code below has to be applied for the api and for the api,
// so has to be moved to a shared place.


// Srtuff needed before validation.
foreach ($resourceCollection as $resourceToInsert) {
// Concept only logic
Expand Down Expand Up @@ -125,9 +122,11 @@ public function handle(Message $message)
} catch (ResourceNotFoundException $e) {
//do nothing
}

//special import logic
if ($resourceToInsert instanceof Concept) {

// @TODO Is that $currentVersion/DATESUBMITTED logic needed at all. Remove and test.
$currentVersion = null;
if (isset($currentVersions[$resourceToInsert->getUri()])) {
/**
Expand Down Expand Up @@ -183,6 +182,12 @@ public function handle(Message $message)
$message->getUser(),
$currentVersion ? $currentVersion->getStatus(): null
);
} elseif ($resourceToInsert instanceof ConceptScheme) {
$resourceToInsert->ensureMetadata(
$this->tenant->getCode(),
$message->getSetUri(),
$message->getUser()
);
}

if (isset($currentVersions[$resourceToInsert->getUri()])) {
Expand Down
2 changes: 1 addition & 1 deletion public/assets/scripts/editor/search.js
Expand Up @@ -62,7 +62,7 @@ EditorSearch = new Class({
// Handle button clicking or other form submit.
this.searchForm.addEvent('submit', function (ev) {
ev.stop();
self.search();
self.delayedSearch();
});

this.initAdvancedOptionsBox();
Expand Down
70 changes: 70 additions & 0 deletions tools/temp/fixLowerCaseConceptScheme.php
@@ -0,0 +1,70 @@
<?php
/**
* OpenSKOS
*
* LICENSE
*
* This source file is subject to the GPLv3 license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.gnu.org/licenses/gpl-3.0.txt
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category OpenSKOS
* @package OpenSKOS
* @copyright Copyright (c) 2015 Pictura Database Publishing. (http://www.pictura-dp.nl)
* @author Alexandar Mitsev
* @license http://www.gnu.org/licenses/gpl-3.0.txt GPLv3
*/


include dirname(__FILE__) . '/../autoload.inc.php';

/*
* Updates the status expired to status obsolete
*/

require_once 'Zend/Console/Getopt.php';
$opts = array(
'env|e=s' => 'The environment to use (defaults to "production")',
);

try {
$OPTS = new Zend_Console_Getopt($opts);
} catch (Zend_Console_Getopt_Exception $e) {
fwrite(STDERR, $e->getMessage()."\n");
echo str_replace('[ options ]', '[ options ] action', $OPTS->getUsageMessage());
exit(1);
}

include dirname(__FILE__) . '/../bootstrap.inc.php';

// Allow loading of application module classes.
$autoloader = new OpenSKOS_Autoloader();
$mainAutoloader = Zend_Loader_Autoloader::getInstance();
$mainAutoloader->pushAutoloader($autoloader, array('Editor_', 'Api_'));

$diContainer = Zend_Controller_Front::getInstance()->getDispatcher()->getContainer();
/* @var $resourceManager \OpenSkos2\Rdf\ResourceManager */
$resourceManager = $diContainer->get('OpenSkos2\Rdf\ResourceManager');

/* @var $conceptSchemeManager \OpenSkos2\ConceptSchemeManager */
$conceptSchemeManager = $diContainer->get('OpenSkos2\ConceptSchemeManager');

use OpenSkos2\Namespaces\Rdf;
use OpenSkos2\Rdf\Uri;
use OpenSkos2\ConceptScheme;

$wrongType = 'http://www.w3.org/2004/02/skos/core#conceptScheme';

$count = 0;
foreach ($resourceManager->fetch([Rdf::TYPE => new Uri($wrongType)]) as $conceptScheme) {
echo $conceptScheme->getUri() . PHP_EOL;
$conceptScheme->setProperty(Rdf::TYPE, new Uri(ConceptScheme::TYPE));
$conceptSchemeManager->replace($conceptScheme);
$count ++;
}

echo $count . ' processed concept schemes.' . PHP_EOL;

0 comments on commit 53b9685

Please sign in to comment.