EPrints Technical Mailing List Archive

See the EPrints wiki for instructions on how to join this mailing list and related information.

Message: #02784


< Previous (by date) | Next (by date) > | < Previous (in thread) | Next (in thread) > | Messages - Most Recent First | Threads - Most Recent First

[EP-tech] Re: Updating Subjects


Eliseo,

I’d support Seb’s response – I always thought my way was ‘hacky’.

Maybe I need to write a tool to do this…

 

Cheers,
John

 

 

From: eprints-tech-bounces@ecs.soton.ac.uk [mailto:eprints-tech-bounces@ecs.soton.ac.uk] On Behalf Of Sebastien Francois
Sent: 17 March 2014 12:05
To: eprints-tech@ecs.soton.ac.uk
Subject: [EP-tech] Re: Updating Subjects

 

Hola,

If I may add to this.... You shouldn't use direct SQL unless there are no other choices - this potentially breaks the relational model.

So instead, you should write a script that transfer objects from one subject id to another, using the EPrints API.

Seb.


On 17/03/14 09:53, John Salter wrote:

Hi Eliseo,

There’s two sides to this:

- getting the new subjects created

- moving eprints from the old subjects to the new ones.

 

If possible, I’d look at getting the new subjects into order first – as you’ve already identified, either via the web interface or the import (you might want to look at the subject export too – which might be useful to do, add your new subjects and then re-import).

Creating a new set of nodes is (IMO) easier than trying to rework the existing ones as they are stored in the database as both child and parent trees, so you’d possibly have to make changes to stuff in all these tables:

subject

subject__index

subject__index_grep

subject__ordervalues_en

subject__rindex

subject_ancestors

subject_name_lang

subject_name_name

subject_parents

 

To move the eprints from one node to another, if it’s a straight swap (e.g. subjectid_A is replaced by subjected_1; subjectid_B is replaced by subjectid_2 etc.), it’s fairly easy to do in the database (you could even clone the eprint_subjects table and do the updates in the new copy to be on the safe side).

 

mysql> UPDATE eprint_subjects SET subject = newSubjectID where subject = oldSubjectID;

 

I find the following query useful to see if there are any subjects use, but not defined:

mysql> select count(*),  subject, pos from eprint_subjects where subject NOT IN (select subjectid from subject) group by subject, pos;

 

Hope that helps a bit – someone else might have some better/easier ways of doing this!

Cheers,

John

 

 

From: eprints-tech-bounces@ecs.soton.ac.uk [mailto:eprints-tech-bounces@ecs.soton.ac.uk] On Behalf Of Eliseo Gatchalian
Sent: 17 March 2014 03:06
To: eprints-tech@ecs.soton.ac.uk
Subject: [EP-tech] Updating Subjects

 

Hi,

 

I know that we can add and edit the subjects by logging in as admin and can also import a subject_xml file, but  If we are to merge some subjects with different subject code into one, is there an automatic way to update the subject codes for the items already submitted in the archive?

 

I saw the eprints_subject table wherein we can replace the subject field with the new codes and update the items but I’m not sure if there are anything else that we need to update?

 

Thanks!

 


 

Ellis Gatchalian
Systems Librarian
Wintec
Private Bag 3036, Waikato Mail Centre, Hamilton 3240
Phone: +64-(0)7-834 8800 ext 8633
Fax: +64-(0)7-838 8257

Email: ellis.gatchalian@wintec.ac.nz

Web: http://www.wintec.ac.nz/

WIN01

 

 

 

 


This electronic mail transmission is intended for the named recipients only. It may contain private and confidential information. If this has come to you in error you must take no action based upon it, nor must you copy it or show it to anyone; please telephone or email the sender at Wintec immediately and return the original email. We cannot accept any liability for any loss or damage sustained as a result of software viruses. It is your responsibility to carry out such virus checking as is necessary before opening any attachment which may be included with this message.




*** Options: http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech
*** Archive: http://www.eprints.org/tech.php/
*** EPrints community wiki: http://wiki.eprints.org/
*** EPrints developers Forum: http://forum.eprints.org/