Getting a person's ORCID using the ORCID API - orcid

Best way to search a user's ORCID via name.
Is there any equivalent to what is essentially this page: https://orcid.org/orcid-search/search in the ORCID API ?
As in, and endpoint where I can just search as /api?name=john%20doe and get back their id as the response ?
Note: The API seems to have documentation, but that documentation doesn't include, as far as I've seen, any guidance to actually using the API, only pages which explain how the api should be used, without giving you the actual urls, query parameters or example calls... :/

Here you see how you have to get an Client_API ID and the secret for searching for ones name.
https://info.orcid.org/documentation/api-tutorials/api-tutorial-searching-the-orcid-registry/#easy-faq-2532

Validating ORCID using javascript
function validOrcID(str) {
/* ORCID format is XXXX-XXXX-XXXX-XXXX. */
if (!str) return false;
testStr = new String(str);
len = testStr.length;
if (len!=19) return false
dashTest = testStr.split('-');
if (dashTest.length !=4) return false;
if (dashTest[0].length !=4 || dashTest[1].length!=4 || dashTest[2].length!=4 || dashTest[3].length!=4) return false
if (isNaN(dashTest[0]) || isNaN(dashTest[1]) || isNaN(dashTest[2]) || isNaN(dashTest[3])) return false
return true;
}

Related

Enhanced ecommerce don't recognize internal promotion view object

I've been implementing all the enhanced eCommerce tracks for the past few weeks and I could do most of the job successfully thanks to Simo Ahava's blog. But now I'm struggling with the internal promotion view tracking.
I choose to implement the view tracking with the concept of True View Impressions also with a base on Simo's work and for products it was ok. So I modified the customTasks from the link to track internal promotion but, for some reason, the enhanced eCommerce isn't recognizing the promoView object. But it's recognizing the promoClick (?).
I've made a test: I substitute the promoClick for a impression object and it works! So, my strong guest, it's that the problem it's really on my object. My object's format can be seen here.
And to illustrate the way the object it's being constructed:
var targetElement = {{Click Element}},
event = {{Event}},
batch = window[promoBatchVariableName],
impressions = google_tag_manager[{{Container ID}}].dataLayer.get('ecommerce.promoView.promotions'),
ecomObj = { };
if (event === 'gtm.click') {
while (!targetElement.getAttribute(promoIdAttribute) && targetElement.tagName !== 'BODY') {
targetElement = targetElement.parentElement;
}
}
var latestPromoImpression = impressions.filter(function(impression) {
return impression.id === targetElement.getAttribute(promoIdAttribute);
}).shift();
var promoImpressionsArr = batch.map(function(id) {
return impressions.filter(function(impression) {
return impression.id === id;
}).shift();
});
if (event === 'gtm.elementVisibility'){
promoImpressionsArr[maxPromoBatch - 1] = latestPromoImpression;
}
console.log(ecomObj)
ecomObj.promoView = { promotions: promoImpressionsArr};
if (event === 'gtm.click') {
ecomObj.promoClick = {
promotions: [latestPromoImpression]
};
console.log("click")
}
return {
ecommerce: ecomObj
};
}
Could someone help me with some ideas?
This answer is just to close the question! As I pointed in the comments:
" I found the problem. And it's not on my object itself only. xD The problem is the undefined elements as you pointed at the beginning of our talk. I'm waiting for the dev team to change the data-attributes of the elements on our site's pages because sometimes we don't get any individual identifier variable. So, in the meantime, I've implemented a way to get always a product id even in these cases but as the identifier doesn't exist in the CSS selector if the element has an id in the 'entrance object', the element is set as undefined. "

Firestore Rules - Validate if data exists in other collection

I'm currently working on my firestore rules and I need to validate the incoming data. Besides what I already have, I also need to validate if the incoming origin and tag fields exist in the collection origins and tags. I've found how to do so when using references but I'm using embedded data so I'm unsure how to exactly do it.
function incomingData() {
return request.resource.data
}
function validTicket() {
return incomingData().email is string &&
incomingData().description is string &&
incomingData().address is string &&
incomingData().location is string &&
incomingData().postCode.matches('^[0-9][0-9][0-9][0-9]-[0-9][0-9][0-9]') &&
incomingData().size() == 5 &&
incomingData().hasAll(['email','description', 'address', 'location', 'postCode']) &&
isSecretary()
}
In the tags collection, every document has a single value with the tag name. The same applies to the origins.
I'm sorry my answer will be partial, i need you to post your current firestore rules, and the name of the ticket collection...
anyway, for tags, you won't be able to search them for their value, and nor inside the rules, so you should save them as keys. that mean, that the key for the document of sports, should be sports, and not 8VCCvq7qnvjyT98r95pu.
next, you will have to use the function exists, in the follow way:
function isTagExists(tag) {
return exists(/databases/$(database)/documents/tags/$(tag));
}
let me know if you updated the question or you need more help with my solution.
also you can read more at:
https://firebase.google.com/docs/firestore/security/rules-conditions

Conditional Search Results

I'm creating a 'Kiosk' where users can sign-in and out.
I'm stuck on the sign-out component.
I'd like to have a table that only returns visitors that have not signed out after the end-user searches.
My search box has the following properties:
Value:
#datasource.query.filters.fullname._startsWith
On value change:
if (widget.value === null || (widget.value).length === 0){
widget.datasource.unload();
} else {
widget.datasource.load();
}
I'm new to this & JS as a whole. How can I filter the search to only contain users that have not signed out?
As suggested in the comments you need to add widget.datasource.query.filters.signedout._equals = false; line before you load your data source. However you should make one more change while unloading.
Here's the full code.
if (widget.value === null || (widget.value).length === 0){
widget.datasource.unload();
widget.datasource.load();
} else {
widget.datasource.unload();
widget.datasource.query.filters.signedout._equals = false;
widget.datasource.load();
}
Here unload() will unload previous data and load() will reload it. Now while reloading you can pass multiple filters so it reloads only filtered records.

Best way to compare two authentication tokens

Consider the following example: http://symfony.com/doc/current/cookbook/security/custom_authentication_provider.html#the-listener
I want to see if the new authenticated token is the same as for the currently logged in user. See below.
try {
$currentToken = $this->securityContext->getToken();
$authToken = $this->authenticationManager->authenticate($token);
// What is the best way to compare these two? Both implement TokenInterface.
if ([compare tokens]) {
// already logged in
return;
}
$this->tokenStorage->setToken($authToken);
return;
} catch (AuthenticationException $failed) {
}
I considered comparing UserInterface->getUsername():
if ($currentToken->getUser()->getUsername() === $authToken->getUser()->getUsername()) {
But wonder if there is a better solution...
I assume both user object aren't the same reference. Because if they are you could compare them using === to check if they are the same.
Given that username is unique than this is one way to check if it is the same user.
But in some systems the username doesn't have to be unique. So comparing the id's might be better since they should alway be unique.
What about leveraging the code they show in the authenticate() function?
$currentUser = $this->userProvider->loadUserByUsername($currentToken->getUsername());
then
$tokenUser = $this->userProvider->loadUserByUsername($authToken->getUsername());
then
if ($currentUser == $tokenUser) {

Dynamics AX: how to filter a report?

I need to add a filter to a report in Dynamics AX 2009. Msdn tell me to filter using Fetch event. So i've added the following code into the fetch.
DateFromDialog and DateToDialog are variable declared into ClassDeclaration.
qrun = new QueryRun(element);
_vendInvoiceJour = qrun.get(TableNum(VendInvoiceJour));
if( _vendInvoiceJour.InvoiceDate <= DateFromDialog.value() || _vendInvoiceJour.InvoiceDate >=DateToDialog.value() ) {
// Exclude record, don't print it
return false;
}
Is it correct to return false if the record must not printed ?
Thanks
No, it is not. If your your first record is to be excluded, the fetch method return false without sending a single record and nothing is printed.
You can return false in the send method. That works but is a poor choice for performance reasons.
The correct way is to add the date range as a query range:
SysQuery::findOrAddRange(element.queryrun().query().findDatasource(tableNum(VendInvoiceJour), fieldNum(VendInvoiceJour,InvoiceDate)).value(queryRange(DateFromDialog.value(), DateToDialog.value()));
I have not tested the code.

Resources