Esri / geoportal-server-catalog

Esri Geoportal Server is a next generation open-source metadata catalog and editor, based on elasticsearch.
https://www.esri.com/en-us/arcgis/products/geoportal-server/overview
Apache License 2.0
97 stars 61 forks source link

Adding additional fields & info in the item card #355

Closed moco32 closed 3 years ago

moco32 commented 3 years ago

I am using a custom profile at the moment with a few extra fields /values and I am trying to add them in the card item, for example.

NovicaJ_1-1615382777952

I've been trying something like this, in the EvaluatorFor_ISO.js but it's not working, I simply cannot add the two new fields in the json

/* general */ G.evalProp(task,item,root,"fileid","gmd:fileIdentifier/*/text()"); G.evalProp(task,item,iden,"title","gmd:citation/gmd:CI_Citation/gmd:title/*/text()"); G.evalProp(task,item,iden,"description","gmd:abstract/gco:CharacterString"); G.evalProps(task,item,root,"keywords_s","//gmd:MD_TopicCategoryCode | //gmd:descriptiveKeywords/gmd:MD_Keywords/gmd:keyword/*/text() "); G.evalProp(task,item,iden,"thumbnail_s","gmd:graphicOverview/gmd:MD_BrowseGraphic/gmd:fileName/gco:CharacterString"); G.evalProps(task,item,root,"contact_organizations_s","//gmd:CI_ResponsibleParty/gmd:organisationName/*/text()"); G.evalProps(task,item,root,"contact_people_s","//gmd:CI_ResponsibleParty/gmd:individualName/*/text()"); G.evalProps(task,item,root,"price","myprofile:price/*/text()"); G.evalProps(task,item,root,"tax","myprofile:tax/*/text()"); Any pointers on how to proceed?

mhogeweg commented 3 years ago

hi, just like you had to do when creating the metadata editor, the evaluators need to know the namespace associated with the prefix myprofile. You can add a URI for this namespace in Evaluator.js. Look for the function G._initializeTask. Make sure you use the same namespace URI in both the editor and the evaluator.

moco32 commented 3 years ago

@mhogeweg So, I'd need something like this in the G._initializeTask nsmap.put("myprofile","what goes here?"); ?

mhogeweg commented 3 years ago

the same as what you have for the namespace URI in the XML editor. Remember in geoportal/app/gxe/types/myprofile/base I said to insert the following function in DataDocumentType.js?

    initializeNamespaces: function() {
      this.addNamespace("myprofile", "http://www.example.com/myprofile");
    }

the namespace URI in this case is http://www.example.com/myprofile (it is a type of URI). myprofile is a namespace prefix, which is a convenient way of referring to a namespace in an XML document without having to include the full URI.

in G.initializeTask you would include:

nsmap.put("myprofile","http://www.example.com/myprofile"); 
moco32 commented 3 years ago

I added the URI in the G.initializeTask as instructed but it's still not working. The field price is still not in the json.

moco32 commented 3 years ago

@mhogeweg maybe I need to add something in the xslt files in web-inf/classes/metadata/xslt?

moco32 commented 3 years ago

@mhogeweg I also tried adding this G.evalProps(task,item,root,"price","myprofile:price/*/text()"); in other evaluators like the Cinergi one. No results again. Any pointers you might have? :)

mhogeweg commented 3 years ago

can you share a sample XML file in this profile?

moco32 commented 3 years ago

@mhogeweg here is a sample XML with the custom myprofile profile

xmlSampleForMarten.zip

moco32 commented 3 years ago

@mhogeweg also, here's the LINK to my geoportal server catalog, if you need it.

mhogeweg commented 3 years ago

I removed the various entries where you tried setting the price/tax fields and only left this in function evalBase() in file EvaluatorFor_ISO.js:

    var price = G.Val.chkDbl(G.getString(task, root, "//myprofile:price/gco:CharacterString/text()"), null);
    G.writeProp(item, "price_f", price);

    var tax = G.Val.chkDbl(G.getString(task, root, "//myprofile:tax/gco:CharacterString/text()"), null);
    G.writeProp(item, "tax_f", tax);

This gets the value of the XML elements using an absolute xpath and then turns that value in a float before storing in the fields. The suffix _f is important as this tells Elastic how to index the value. This also makes it possible to use the tax/price values in search facets.

moco32 commented 3 years ago

@mhogeweg I also removed all the entries for price/tax and only left the above lines of code you have provided me with but I still don't have the price or tax fields in the json. This is what my json looks like

json.zip

moco32 commented 3 years ago

@mhogeweg I also tried replacing the item & root variable with iden, but I still get no changes in the JSON.

mhogeweg commented 3 years ago

I emailed a link to Novica to a onedrive folder with the updated geotest webapp. I also configured a search facet for price:

image