[Isis-users] Global Change

Jean-Claude Dauphin jc.dauphin at gmail.com
Tue Dec 5 18:35:49 CET 2017


​​
​​
Hello Fred,

You can export yr database into an iso file and import into J-ISIS. Then
you can write a Groovy script to reformat your records.

Once your database OK, you can export the database into an iso file and get
it back into ABCD.

You will finds below a small script example.

Best wishes,

JC

#! v215Corrector_1

import org.unesco.jisis.corelib.common.IConnection
import org.unesco.jisis.corelib.client.ConnectionNIO
import org.unesco.jisis.corelib.client.ClientDbProxy
import org.unesco.jisis.corelib.common.IDatabase
import org.unesco.jisis.corelib.common.Global
import org.unesco.jisis.corelib.record.IRecord
import org.unesco.jisis.corelib.record.Record
import org.unesco.jisis.corelib.record.IField
import org.unesco.jisis.corelib.record.StringOccurrence
import org.unesco.jisis.corelib.record.Subfield

class Corrector {

    private ClientDbProxy db ;

    Corrector(String dbName) {
        // Initialize the server parameters
        def username = "admin";
        def password = "admin";
        def port = "1111";
        def hostname = "localhost";
        def dbHome = "DEF_HOME";
        // Establish a connection to the server
        def connection = ConnectionNIO.connect(hostname,
Integer.valueOf(port), username, password);

        // Create a Database object bind to this server
        db = new ClientDbProxy(connection)


        // Open the database
         db.getDatabase(dbHome, dbName, Global. DATABASE_DURABILITY_WRITE)
         //db.getDatabase(dbHome, dbName, Global. DATABASE_BULK_WRITE)
    }

    def correctDb() {
       Record currentRecord ;
        // Get first record
       currentRecord = db.getFirst();
        // Iterate over the records in the database until nomore


        def i = 0 ;
        //while (i < 10) {
        while (currentRecord != null) {
            // Process the record->
            processRecord(i, currentRecord) ;

            i += 1 ;

            // Get the next sequential record in the mfn order
            currentRecord = db.getNext();
        }
        // Close the database
        db.close();

    }

    def processRecord(i, rec) {
        String doctype = "" ;
        String v215 = "" ;
        Long mfn = rec.getMfn() ;

        IField field ;

        //sous-champ 1
        field =rec.getField(1) ;
        def occ = field.getOccurrence(0) ;
        if (occ != null) {
            doctype = occ.getSubfield('a') ;
        }


        // sous-champ 215
        field = rec.getField(215) ;
        occ = field.getOccurrence(0) ;
        // s'il existe
        if (occ != null && occ.hasSubfields()) {
            Subfield[] subfields = occ.getSubfields() ;
            if (subfields.length == 1 && subfields[0].getSubfieldCode() ==
'a') {
                v215 = occ.getSubfield('a') ;
            }
        }
        if (doctype=="ART" && v215=="1 vol. ()" ) {
             println '\n==========\nrecord corrected mfn : ' + mfn +'
doctype:'+ doctype + ' field value:' + field.getStringFieldValue() ;

             rec.removeField(215) ;

             db.updateRecordEx(rec) ;
        }
    }

}

def corrector=new Corrector("Albert-Groovy") ;
corrector.correctDb() ;

On Tue, Dec 5, 2017 at 5:36 PM, fred train <fred_train at xs4all.nl> wrote:

> Hello guru's
>
> We have repeatable field called Keywords.
> This field contains for historical reasons also coded location information.
> A Keyword field could have entries like
> Colored; upside; metal; painted; GLD; LIM; NLD; sale
> The semicolons are added by the PFT. Each keyword has its own record.
>
> We have created a new repeatable field called Locations. And the location
> entries from the keywords should be moved to the new Locations field and
> also translated into more readable strings.
> The end-effect after the operation should look like:
>
> Keyword: Colored; upside; metal; painted; sale
> Locations: Gelderland(GLD); Limburg(LIM); Netherlands
>
> The idea was to apply a global change for each of the keywords GLD, LIM
> and NLD.
> I can modify the strings into their target strings (e.g. GLD becomes
> Gelderland) in the keywords.
> But the Move option in Global change moves all entries of Keyword to
> Locations.
>
> Is there a solution for my problem?
> In other words: Is it possible with Global Change or another option to
> move some entries from the source repeatable field to a target repeatable
> field?
> Regards
> Fred
>
> _______________________________________________
> isis-users mailing list
> isis-users at iccisis.org
> To manage your own subscription options go to:
> http://lists.iccisis.org/listinfo/isis-users
> Or contact Henk Rutten: hlrutten at xs4all.nl
>



-- 
Jean-Claude Dauphin

jc.dauphin at gmail.com

https://github.com/J-ISIS <http://kenai.com/projects/j-isis/>

http://www.unesco.org/isis/
http://www.unesco.org/idams/
http://www.greenstone.org

On Tue, Dec 5, 2017 at 5:36 PM, fred train <fred_train at xs4all.nl> wrote:

> Hello guru's
>
> We have repeatable field called Keywords.
> This field contains for historical reasons also coded location information.
> A Keyword field could have entries like
> Colored; upside; metal; painted; GLD; LIM; NLD; sale
> The semicolons are added by the PFT. Each keyword has its own record.
>
> We have created a new repeatable field called Locations. And the location
> entries from the keywords should be moved to the new Locations field and
> also translated into more readable strings.
> The end-effect after the operation should look like:
>
> Keyword: Colored; upside; metal; painted; sale
> Locations: Gelderland(GLD); Limburg(LIM); Netherlands
>
> The idea was to apply a global change for each of the keywords GLD, LIM
> and NLD.
> I can modify the strings into their target strings (e.g. GLD becomes
> Gelderland) in the keywords.
> But the Move option in Global change moves all entries of Keyword to
> Locations.
>
> Is there a solution for my problem?
> In other words: Is it possible with Global Change or another option to
> move some entries from the source repeatable field to a target repeatable
> field?
> Regards
> Fred
>
> _______________________________________________
> isis-users mailing list
> isis-users at iccisis.org
> To manage your own subscription options go to:
> http://lists.iccisis.org/listinfo/isis-users
> Or contact Henk Rutten: hlrutten at xs4all.nl
>



-- 
Jean-Claude Dauphin

jc.dauphin at gmail.com

https://github.com/J-ISIS <http://kenai.com/projects/j-isis/>

http://www.unesco.org/isis/
http://www.unesco.org/idams/
http://www.greenstone.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.iccisis.org/pipermail/isis-users/attachments/20171205/0062906d/attachment.html>


More information about the isis-users mailing list