41
FLAT Deposit User Interface Documentation Documentation Release 1.0 Daniel von Rhein Mar 29, 2018

FLAT Deposit User Interface Documentation Documentation

  • Upload
    others

  • View
    34

  • Download
    0

Embed Size (px)

Citation preview

Page 1: FLAT Deposit User Interface Documentation Documentation

FLAT Deposit User InterfaceDocumentation Documentation

Release 1.0

Daniel von Rhein

Mar 29, 2018

Page 2: FLAT Deposit User Interface Documentation Documentation
Page 3: FLAT Deposit User Interface Documentation Documentation

Contents

1 Setup Module 31.1 Installing the FLAT module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

2 Drupal 7 General 52.1 Books . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52.2 Hompepages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52.3 Useful Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

3 Drupal 7 Module Building 7

4 Drupal Receipes 94.1 Rendered page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

5 Drupal 7 Theming 11

6 Render arrays 13

7 Form API 15

8 Fedora /Tuque Links 178.1 Fedora metadata query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

9 API-A and API-M 19

10 Setup 21

11 OwnCloud Command line (OCC) 23

12 OC APIs 25

13 References 27

14 Script Ingest 2914.1 The pipeline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2914.2 Structure of CMDI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

15 Sphinx cheat sheet 3115.1 Formatting text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3115.2 Making a list . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

i

Page 4: FLAT Deposit User Interface Documentation Documentation

15.3 Making a table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3215.4 Making links . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3215.5 This file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

16 Commandline cheats 35

17 Indices and tables 37

ii

Page 5: FLAT Deposit User Interface Documentation Documentation

FLAT Deposit User Interface Documentation Documentation, Release 1.0

Contents:

Contents 1

Page 6: FLAT Deposit User Interface Documentation Documentation

FLAT Deposit User Interface Documentation Documentation, Release 1.0

2 Contents

Page 7: FLAT Deposit User Interface Documentation Documentation

CHAPTER 1

Setup Module

1.1 Installing the FLAT module

In principle, installing the module works as for every other module. Git clone repository tosites/all/modules/custom/<module_name>, log in as admin (admin:admin) and then activate module. However,several extra modules are required. An overview of all dependencies is listed in the moduleName.info file.

On install, hook_install (in myModule.install) and hook_enable (in myModule.module) is being called. If the name ofthe module is flat_deposit search for function flat_deposit_install.

The most important elements added by the base module are different field types, field instances, two node types(Bundles (machine name:flat_bundle) and Collection machine name: flat_collections)), that contain these field typesand the modules variables.

For every field, a table is created in the drupal database with the name field_data_{fieldInstanceName}. Variables aresaved as serialized string in the variables table

Fields for a Bundle are: * title: Node module element * flat_parent_nid: Drupal node id (nid) of the parent collection* flat_policies * flat_cmdi_file (managed) metadata file attached to bundle * flat_bundle_status processing status ofbundle * flat_exception (deprecated) Text containining the error message of a failed upload * flat_parent_title Nameof the parent * flat_source source for Resource files (external or local workspaces) * flat_original_path path of thefiles on file system (uses stream wrappers) * flat_location current location where files should be found * flat_external(deprecated) info if file location is external * flat_type kind of upload. Can be either completely new or update *flat_fid the fedora commons ID associated with the bundle. If empty bundle is new.

Fields for a Collection are: * title: Node module element * flat_fid the fedora commons ID associated with thecollection. This is never empty as a collection is a kind of shortcut to a fedora commons object * flat_collection_statusprocessing status of bundle * flat_exception (deprecated) Text containining the error message of a failed upload *flat_parent_nid (deprecated) Drupal node id (nid) of the parent collection * flat_fid_super Fedora commons ID of theparent of the collection (IsMemberOf property)

3

Page 8: FLAT Deposit User Interface Documentation Documentation

FLAT Deposit User Interface Documentation Documentation, Release 1.0

4 Chapter 1. Setup Module

Page 9: FLAT Deposit User Interface Documentation Documentation

CHAPTER 2

Drupal 7 General

2.1 Books

• The programmer’s guide to drupal by Jennifer Hodgon (also with a git repository)

• Drupal 7 Development by Example by Kurt Madel

• Drupal 7 Module Development by Matt Butcher

• Maybe interesting Drupal 7 Themes by Ric Shreves

2.2 Hompepages

• Drupal Example Project with a well documented API

• Site for evaluating drupal modules

2.3 Useful Modules

• Drupal Examples

• Admin_menu

• Devel

5

Page 10: FLAT Deposit User Interface Documentation Documentation

FLAT Deposit User Interface Documentation Documentation, Release 1.0

6 Chapter 2. Drupal 7 General

Page 11: FLAT Deposit User Interface Documentation Documentation

CHAPTER 3

Drupal 7 Module Building

• Drupal 7 Custom Module Development with Jon Peck

• Drupal 7 Essential Training with Tom Geller

• Drupal 7: Reporting and Visualizing Data with Tom Geller

7

Page 12: FLAT Deposit User Interface Documentation Documentation

FLAT Deposit User Interface Documentation Documentation, Release 1.0

8 Chapter 3. Drupal 7 Module Building

Page 13: FLAT Deposit User Interface Documentation Documentation

CHAPTER 4

Drupal Receipes

4.1 Rendered page

Make in your module an implementation of hook_menu, specifying the path of your page. Here you can define afunction call (e.g. page_call_info()), specifying what and how to render:

# Item of hook_menu$items['commitchanges'] = array(

'title' => 'Commit changes','page callback' => 'flat_deposit_ui_view_info','access callback' => TRUE,'page arguments' => array(

'content' => 'Under construction'),

9

Page 14: FLAT Deposit User Interface Documentation Documentation

FLAT Deposit User Interface Documentation Documentation, Release 1.0

10 Chapter 4. Drupal Receipes

Page 15: FLAT Deposit User Interface Documentation Documentation

CHAPTER 5

Drupal 7 Theming

Theming is one of the major issues of the drupal framework, particular if you think of this framework as a giganticwrapper. For sure, Drupal does much more than that, but in the end, what you see is a in HTML-rendered homepage,so it is good to know something about rendering

11

Page 16: FLAT Deposit User Interface Documentation Documentation

FLAT Deposit User Interface Documentation Documentation, Release 1.0

12 Chapter 5. Drupal 7 Theming

Page 17: FLAT Deposit User Interface Documentation Documentation

CHAPTER 6

Render arrays

Render arrays are arrays containing fields that are used to render different content. The most basis type is the markuptype, containing with hard coded content. You can specify the output as it is shown on a HTML-page.

'link_upload' => array('#type' => 'markup','#prefix' => '<div>','#markup' => '<a href="/drupal/user/' . $GLOBALS['user']->uid . '/imce"

→˓title="Upload data"><img title="Upload data" alt="Upload data" src="/drupal/sites/→˓default/files/Upload.png"/></a><br/>',

'#suffix' => </div>')

But there are also a lot of other types. Depending on the type of element which needs to be rendered (e.g. tables) thesemay have an theme function that can be called to wrap the content of the array in a certain format. An overview of allavailable functions are here

Videos (google render arrays drupal 7 tutorial):

• Themes tutorial by Heather James

• Drupal 7 renderable arrays by Code Carate

Pages:

• Themery.com

Books:

all the resources mentioned here Books)

13

Page 18: FLAT Deposit User Interface Documentation Documentation

FLAT Deposit User Interface Documentation Documentation, Release 1.0

14 Chapter 6. Render arrays

Page 19: FLAT Deposit User Interface Documentation Documentation

CHAPTER 7

Form API

The form api is an important means to interact with the user. You can define for example action buttons and use themto trigger certain events. Normally, this procedure involves several steps.

1. Create a function containing your form

2. Call this form from your menu

3. Create an additional form_validate function

4. Create a form_submit function

Resources:

• Form API reference

15

Page 20: FLAT Deposit User Interface Documentation Documentation

FLAT Deposit User Interface Documentation Documentation, Release 1.0

16 Chapter 7. Form API

Page 21: FLAT Deposit User Interface Documentation Documentation

CHAPTER 8

Fedora /Tuque Links

Tuque Fedora REST API

8.1 Fedora metadata query

Fedora meta data can be queried in two different way, either using the SPARQL or iTQL query language. iTQL ismore in the MySQL fashion, but the Islandora programmers prefer the SPARQL language. There is a interface on thefedora server, which can be reached by entering <fedora_host>/risearch.

There you can play with the queries and test them before they you implement them. Here are two example queries

SPARQL:

PREFIX fm: <info:fedora/fedora-system:def/model#>PREFIX fv: <info:fedora/fedora-system:def/view#>SELECT ?label ?created FROM <#ri>WHERE {?object <http://purl.org/dc/elements/1.1/identifier> ?pid.?object fm:state fm:Active.?object fm:label ?label.?object fm:createdDate ?created.?object fm:ownerId 'admin'.?object fv:disseminates ?disFilter REGEX (STR(?dis),'OBJ')}

iTQL:

SELECT $object $created from <#ri>WHERE $object <info:fedora/fedora-system:def/model#hasModel> <info:fedora/→˓islandora:sp_cmdiCModel>AND <info:fedora/fedora-system:def/model#createdDate> $created

Useful links for this resource:

17

Page 22: FLAT Deposit User Interface Documentation Documentation

FLAT Deposit User Interface Documentation Documentation, Release 1.0

• Fedora Research index

• Islandora Tuque documentation

• Sparql tutorial

• W3.org sparql site

• linkedin spreadsheets

18 Chapter 8. Fedora /Tuque Links

Page 23: FLAT Deposit User Interface Documentation Documentation

CHAPTER 9

API-A and API-M

Retrieval and modification of data/info stored on the fedora server is quite easy using tuque. For reading actions theAPI-A has been programmed, for writing the API-M. All actions are stored in methods that are bound to fedora objectclasses. Here are two examples for running a simple query (A) and changing the ownership of a file (M):

$tuque = islandora_get_tuque_connection();#API-A$api_a = $tuque->repository->api->a;$condition = "ownerId=" . $GLOBALS['user']->name;$results = $api_a->findObjects('query',$condition);

#API-A$api_m = $tuque->repository->api->m;$pid = $result2['pid'];$commit = $api_m->modifyObject($pid, array('ownerId' => 'admin', 'logMessage' =>→˓'Daniels api-m test' ));

19

Page 24: FLAT Deposit User Interface Documentation Documentation

FLAT Deposit User Interface Documentation Documentation, Release 1.0

20 Chapter 9. API-A and API-M

Page 25: FLAT Deposit User Interface Documentation Documentation

CHAPTER 10

Setup

1. Get packages

2. set rights of owncloud files to HTTP user

3. create owncloud database (on mysql or postgres server)

4. Use owncloud console as HTTP user (sudo -u www-data php /var/www/owncloud/occ)

5. Change rights of all files in folder as recommended on the site

6. Add domain through which owncloud can be assessed to the config.php file

21

Page 26: FLAT Deposit User Interface Documentation Documentation

FLAT Deposit User Interface Documentation Documentation, Release 1.0

22 Chapter 10. Setup

Page 27: FLAT Deposit User Interface Documentation Documentation

CHAPTER 11

OwnCloud Command line (OCC)

adding a user:

sudo -u www-data php occ user:add --display-name="Daniel von Rhein" --group="users" --→˓group="TLA" danrhe

23

Page 28: FLAT Deposit User Interface Documentation Documentation

FLAT Deposit User Interface Documentation Documentation, Release 1.0

24 Chapter 11. OwnCloud Command line (OCC)

Page 30: FLAT Deposit User Interface Documentation Documentation

FLAT Deposit User Interface Documentation Documentation, Release 1.0

26 Chapter 12. OC APIs

Page 32: FLAT Deposit User Interface Documentation Documentation

FLAT Deposit User Interface Documentation Documentation, Release 1.0

28 Chapter 13. References

Page 33: FLAT Deposit User Interface Documentation Documentation

CHAPTER 14

Script Ingest

14.1 The pipeline

De Hocank data is op verschillende MPI servers gemount, e.g., ssh.mpi.nl

scp [email protected]:/home/menwin/tmp/hocank-data.tgz .tar xvfz /home/menwin/tmp/hocank-data.tgz

Je kunt de docker container opstarten met de Hocank data gemount

docker run -p 80:80 -p 8443:8443 -v ../../hocank-data/:/lat -t -i flat

In de container bevindt je je direct in de /app/flat directory. Voer daar de volgende commando’s uit

mkdir srccd srcln -s /lat/Hocank .cd ..ln -s /lat/imdi-to-skip.txt ../do-0-convert.sh # create empty directory structure resembling the origin; create→˓cmdi meta data files in directory Metadata directory./do-1-fox.sh # create FOXML files for each specific file./do-2-import.sh # java script to ingest data based on FOXML file./do-3-config-cmd-gsearch.sh./do-4-index.sh

Nu kun je naar je browser en in FLAT grasduinen:

• http://192.168.99.100/drupal

De default login is:

• admin/admin

29

Page 34: FLAT Deposit User Interface Documentation Documentation

FLAT Deposit User Interface Documentation Documentation, Release 1.0

14.2 Structure of CMDI

In the CMDI file, you define the structure of your project. Thus, there is one CMDI per project/measure. Wheningesting a project, for all files plus the metadata files FOXML objects are created and ingested.

The structure of each CMDI is as follows

Header: here you define the ID of your metadata file and maybe other important things.

<MdCreator> I don"t know </MdCreator><MdCreationDate>2007-11-26</MdCreationDate><MdSelfLink> The part following the colon will become the PID (slash and score will→˓become underscore </MdSelfLink><MdProfile>clarin.eu:cr1:p_1407745712035</MdProfile>

Resources: Here you specify the files associated with the meta file. Make sure to specify both resource and metadatafile.

<ResourceProxy id="d333e522"> //this id needs to be unique and will be used later on<ResourceType mimetype="audio/x-mpeg3">Resource</ResourceType> //important to

→˓render the file in the correct way<ResourceRef lat:localURI="/path/to/File.mp3">hdl:use-unique-PID</ResourceRef>

<ResourceProxy id="landingpage"> //don|t know if the specific id name is necessary to→˓qualify meta data files

<ResourceType>LandingPage</ResourceType> //same is true for type and ref<ResourceRef>hdl:1839/00-0000-0000-0016-7DE4-4</ResourceRef>

We can customize a CMDI file and generate a FOXML file from it. Therefore, we need to link the users workspace inthe /app/flat/src directory and then run the scripts as indicated above.

In order to see the data on the fedora server, we need to change a parameter in our native fedora config file(/var/www/fedora/server/config/fedora.fcfg):

<param name="ENFORCE-MODE" value="permit-all-requests"/>

And, of course, restart the fedora server:

/var/www/fedora/tomcat/bin/tomcat-fedora.sh start

30 Chapter 14. Script Ingest

Page 35: FLAT Deposit User Interface Documentation Documentation

CHAPTER 15

Sphinx cheat sheet

Here is a quick and dirty cheat sheet for some common stuff you want to do in sphinx and ReST. You can see theliteral source for this sheet here This file. More basic documentation can be found at this resources:

• Documentation guide

• ReST syntax

• More advanced topics are covered here

15.1 Formatting text

You use inline markup to make text italics, bold, or monotype.

You can represent code blocks fairly easily:

import numpy as npx = np.random.rand(12)

Or literally include code:

from pylab import *from matplotlib.patches import Ellipse

delta = 45.0 # degrees

angles = arange(0, 360+delta, delta)ells = [Ellipse((1, 1), 4, 2, a) for a in angles]

a = subplot(111, aspect='equal')

for e in ells:e.set_clip_box(a.bbox)e.set_alpha(0.1)a.add_artist(e)

31

Page 36: FLAT Deposit User Interface Documentation Documentation

FLAT Deposit User Interface Documentation Documentation, Release 1.0

xlim(-2, 4)ylim(-1, 3)

show()

15.2 Making a list

It is easy to make lists in rest

15.2.1 Bullet points

This is a subsection making bullet points

• point A

• point B

• point C

15.2.2 Enumerated points

This is a subsection making numbered points

1. point A

2. point B

3. point C

15.3 Making a table

This shows you how to make a table – if you only want to make a list see Making a list.

Name AgeJohn D Hunter 40Cast of Thousands 41And Still More 42

15.4 Making links

It is easy to make a link to yahoo or to some section inside this document (see Making a table) or another document.

You can also reference classes, modules, functions, etc that are documented using the sphinx autodoc facilites. Forexample, see the module matplotlib.backend_bases documentation, or the class LocationEvent, or themethod mpl_connect().

32 Chapter 15. Sphinx cheat sheet

Page 37: FLAT Deposit User Interface Documentation Documentation

FLAT Deposit User Interface Documentation Documentation, Release 1.0

15.5 This file

.. _cheat-sheet:

******************Sphinx cheat sheet

******************

Here is a quick and dirty cheat sheet for some common stuff you wantto do in sphinx and ReST. You can see the literal source for thissheet here :ref:`cheatsheet-literal`. More basic documentation can be found at this→˓resources:

* `Documentation guide <https://docs.python.org/devguide/documenting.html>`_

* `ReST syntax <http://openalea.gforge.inria.fr/doc/openalea/doc/_build/html/source/→˓sphinx/rest_syntax.html>`_

* `More advanced topics are covered here <http://build-me-the-docs-please.readthedocs.→˓org/en/latest/Using_Sphinx/ShowingCodeExamplesInSphinx.html>`_

.. _formatting-text:

Formatting text===============

You use inline markup to make text *italics*, **bold**, or ``monotype``.

You can represent code blocks fairly easily::

import numpy as npx = np.random.rand(12)

Or literally include code:

.. literalinclude:: pyplots/ellipses.py

.. _making-a-list:

Making a list=============

It is easy to make lists in rest

Bullet points-------------

This is a subsection making bullet points

* point A

* point B

* point C

Enumerated points------------------

This is a subsection making numbered points

15.5. This file 33

Page 38: FLAT Deposit User Interface Documentation Documentation

FLAT Deposit User Interface Documentation Documentation, Release 1.0

#. point A

#. point B

#. point C

.. _making-a-table:

Making a table==============

This shows you how to make a table -- if you only want to make a list see→˓:ref:`making-a-list`.

================== ============Name Age================== ============John D Hunter 40Cast of Thousands 41And Still More 42================== ============

.. _making-links:

Making links============

It is easy to make a link to `yahoo <http://yahoo.com>`_ or to somesection inside this document (see :ref:`making-a-table`) or anotherdocument.

You can also reference classes, modules, functions, etc that aredocumented using the sphinx `autodoc<http://sphinx.pocoo.org/ext/autodoc.html>`_ facilites. For example,see the module :mod:`matplotlib.backend_bases` documentation, or theclass :class:`~matplotlib.backend_bases.LocationEvent`, or the method:meth:`~matplotlib.backend_bases.FigureCanvasBase.mpl_connect`.

.. _cheatsheet-literal:

This file=========

.. literalinclude:: cheatsheet.rst

34 Chapter 15. Sphinx cheat sheet

Page 39: FLAT Deposit User Interface Documentation Documentation

CHAPTER 16

Commandline cheats

1. Search folder for files with certain string in it:

egrep -Ric --color $str $folder

2. Access postgres database interactive shell / export data:

pg_dump -U fedora -W -h localhost -d postgres -f /lat/dump1.sqlpsql -U fedora -W -h localhost -d postgres -f /lat/dump1.sql

35

Page 40: FLAT Deposit User Interface Documentation Documentation

FLAT Deposit User Interface Documentation Documentation, Release 1.0

36 Chapter 16. Commandline cheats

Page 41: FLAT Deposit User Interface Documentation Documentation

CHAPTER 17

Indices and tables

• genindex

• modindex

• search

37