Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the CollectiveAccess support forum! Here the developers and community answer questions related to use of the software. Please include the following information in every new issue posted here:

  1. Version of the software that is used, along with browser and version

  2. If the issue pertains to Providence, Pawtucket or both

  3. What steps you’ve taken to try to resolve the issue

  4. Screenshots demonstrating the issue

  5. The relevant sections of your installation profile or configuration including the codes and settings defined for your local elements.


If your question pertains to data import or export, please also include:

  1. Data sample

  2. Your mapping


Answers may be delayed for posts that do not include sufficient information.

Serial ID numbers in import

Hi!

I use an automatic ID numbering structure for collections, which has a SERIAL part in it. It works fine when I manually create an item.
I would like to import a large set of collections and I would like the import to generate ID numbers according to the rule configured in multipart_id_numbering.conf

I have found in Cookbook Chapter 3 that the solution for this issue is to set a mapping like this: Rule Type: Constant Source: % Target: ca_collections.idno
Well, I set it, but it doesn't work for me. Idno is % for every imported items. Import treats '%' sign really as a constant and not like a placeholder.

Do you have any suggestions?

Thanks,
Laszlo

Comments

  • Hi, Try using "mapping" instead of the "constant" rule. I believe the Cookbook is in error.

    As long as your numbering is configured to SERIAL properly, mapping|% should work.

    Jonathan
  • edited February 16
    Hi Jonathan,

    Thank you for your help, but it doesn't work. Mapping|% results empty idno.

    But I found out something.
    In multipart_id_numbering.conf I configured complex rule: depending on the type I have different CONSTANT as a prefix and then a SERIAL number. (It works fine when I manually create an item.) And I have a __default__ case which is FREE type.
    However, the import puts the items into the proper type (as configured in mapping), the numbering runs always onto the default route. As it is FREE, it remains "%".
    I don't know how to redirect numbering to the rule of the given type.

    Laszlo
  • Do you have any suggestion?
  • The % mapping will only work if the id numbering is set to Serial as in:

        ca_objects = {
            __default__ = {
                separator =,
               
                elements = {
                    accession_number = {
                        type = SERIAL,
                        width = 30,
                        editable = 1,
                       
                        description = _(Accession number),
                        table = ca_objects,
                        field = idno,
                        sort_field = idno_sort,
                    }
                }
            }
    },

    It sounds like your number actually has mutliple components. Have you tried using the option "formatWithTemplate" to set the prefix followed by % ?

    Something like {"formatWithTemplate":"^yourprefix.%"}

    I'm not 100% sure that will work as I haven't run into this issue before. But it's something to try.
  • edited February 16
    Hi Jonathan,

    Thank you for your answer. I have already tried something similar and it didn't work. 
    But your suggestion gave me an idea, and finally I could solve the issue. I write down the whole issue and the process of the solution, perhaps it can help for other users, and perhaps it helps you to fix it in the software. (Sorry, it will be a long comment.)

    My multipart_id_numbering.conf contained the following part:
    ca_collections = {
    __default__ = {
    separator =,
    elements = {
    type = FREE,
    width = 30,
    description = _(Identifier),
    editable = 0
    }
    },
    artwork_category = {
    separator =,
    elements = {
    code = {
    type = CONSTANT,
    value = C_AR_,
    description = _(Identifier),
    editable = 0
    },
    ar_number = {
    type = SERIAL,
    zeropad_to_length = 5,
    description = _(Identifier),
    editable = 0,
    table = ca_collections,
    field = idno,
    sort_field = idno_sort
    }
    }
    },
    keyword = {
    separator =,
    elements = {
    code = {
    type = CONSTANT,
    value = C_KE_,
    description = Collection code,
    editable = 0
    },
    ke_number = {
    type = SERIAL,
    zeropad_to_length = 5,
    description = _(Identifier),
    editable = 0,
    table = ca_collections,
    field = idno,
    sort_field = idno_sort
    }
    }
    }
    },

    My mapping was like this:























    Rule type Source CA table.element
    Mapping 1 ca_collections.preferred_labels
    Mapping 2 ca_collections.type_id
    Constant % ca_collections.idno
    Result: all imported collection got '%' as ID. 

    Then I tried this mapping:




























    Rule type Source CA table.element Original values Replacement values
    Mapping 1 ca_collections.preferred_labels
    Mapping 2 ca_collections.type_id
    Mapping 2 ca_collections.idno artwork_category

    keyword
    C_AR_%

    C_KE_%
    Result: collections got 'C_AR_%' or 'C_KE_%' as ID depending on their type.

    It is because the importer always uses the __default__ rule from the numbering.conf

    Solution #1:
    I modified setIdnoWithTemplate function in file \app\lib\ca\BundlableLabelableBaseModelWithAttributes.php
    I added this: if ($this->getTypeCode()) $this->opo_idno_plugin_instance->setType($this->getTypeCode());
    before this line: $vs_gen_idno = $this->opo_idno_plugin_instance->htmlFormValue($vs_idno_field, $ps_template_value); (around line 6400)

    I works fine but there are 3 problems with it:
    1. I am not sure this is the proper solution as I don't know the whole code of the software.
    2. It still doesn't solve the case when I create collections with collectionSplitter refinery in another importer.
    3. I am about to use your hosting service, so unique code modification is not an option for me.

    So you gave me the idea to modify __default__ rule in numbering.conf. I tried different versions, but FREE, CONSTANT or ALPHANUMERIC types (combined with SERIAL) didn't help.

    Solution #2:
    My multipart_id_numbering.conf looks like this:
    ca_collections = {
    __default__ = {
    separator =,
      elements = {
    code = {
    type = LIST,
    values = [C_AR_,C_KE_]
    description = _(Identifier),
    editable = 0
    },
    number = {
    type = SERIAL,
    zeropad_to_length = 5,
    description = _(Identifier),
    editable = 0,
    table = ca_collections,
    field = idno,
    sort_field = type_id\,idno_sort
    }
    }

    },
    artwork_category = {
    separator =,
    elements = {
    code = {
    type = CONSTANT,
    value = C_AR_,
    description = _(Identifier),
    editable = 0
    },
    ar_number = {
    type = SERIAL,
    zeropad_to_length = 5,
    description = _(Identifier),
    editable = 0,
    table = ca_collections,
    field = idno,
    sort_field = idno_sort
    }
    }
    },
    keyword = {
    separator =,
    elements = {
    code = {
    type = CONSTANT,
    value = C_KE_,
    description = Collection code,
    editable = 0
    },
    ke_number = {
    type = SERIAL,
    zeropad_to_length = 5,
    description = _(Identifier),
    editable = 0,
    table = ca_collections,
    field = idno,
    sort_field = idno_sort
    }
    }
    }
    },

    With mapping:

































    Rule type Source CA table.element Original values Replacement values
    Mapping 1 ca_collections.preferred_labels
    Mapping 2 ca_collections.type_id
    Mapping 2 ca_collections.idno artwork_category

    keyword
    C_AR_%

    C_KE_%

    Serial numbers are generated, it works like a charm.

    Laszlo
Sign In or Register to comment.