How can I express the equivalent of the is-accessible attribute using Dozer API Mappings? - dozer

The Dozer API Mappings example page does not say how to specify the equivalent of the is-accessible XML attribute. Is it possible?

You can do something like this:
mapping(clazzA, clazzB).fields(
field("fieldnameA").accessible(true),
field("fieldnameB").accessible(true))

Related

SuiteTalk SOAP API CustomFieldSearch in Java

I am using the Java proxies downloaded from http://content.netsuite.com/download/NSJavaClient2021-2.zip
Given a CustomFieldRef (with say, InternalId "30"), how do I fetch the name of this CustomField? In short, is there a CustomFieldSearch to search all CustomFields?
In the soap world, you'll want to think of the CustomField as the superclass for a number of specialized classes like TransactionBodyCustomField or EntityCustomField. From there, you can access the record using a standard get call. I'm not familiar with the java-proxies, but in python, we'd do something like:
f = soap.get('transactionBodyCustomField', '30')
which would send an xml body with the appropriate recordRef xml.

How to add query parameter to routes in Lumen?

I am trying to know how to add query parameters to routes in Lumen
this is an example of a route I created
$app->get('/product/{apikey}','ProductController#getProduct');
This works when I use
http://api.lumenbased.com/product/10920918
but I would like to use it like this
http://api.lumenbased.com/product/?apikey=10920918
I tried this
$app->get('/product/?apikey={apikey}','ProductController#getProduct');
But this gives me MethodNotAllowedHttpException
I would like to know how to write routes with query parameters in Lumen ?
Just do:
$app->get('/product','ProductController#getProduct');
and use:
$request->get('apikey')
in the ProductController#getProduct function.
(That said, validating an API key is better done via middleware...)

In Symfony2 what is the best way to use a multi word name and get a good RESTful url

I'm using the FOSRestBundle to build my symfony2 API.
I have entities called things like SupportRequestTemplate, which I would like to see in the API end point but when I create the Actions with names like
getSupportRequestTemplateAction(Request $request, $id) {}
FOSRest treats each camel case word as a new Resource name, so the url I get is
/api/supports/{id}/request/template.json
which looks pretty bad. Is there a way to get the end points to look like this instead.
/api/support-request-templates/{id}.json
Or will I just have to suck it up and go to all lower case for something like
/api/supportrequesttemplates/{id}.json
You can use annotations to customise the url according to your needs.
For example #Get:
use FOS\RestBundle\Controller\Annotations as Rest;
/**
* #Rest\Get("/api/support-request-templates/{id}.json")
*/
public function getSupportRequestTemplateAction($id, Request $request)
{
...
}
You can read more about these annotations in manual definition of routes.

How to provide translations for field names with Symfony2/Doctrine2 via REST?

We have a backend built on FOSRestBundle (JMSSerializer) based on Symfony2/Doctrine2.
Our API e.g. delivers for some entity something like: 'valid_from': '2015-12-31' in a REST/JSON response.
Our AngularJS frontend consumes this REST API and e.g. presents some form to the user:
Valid from: 31.12.2015
Now I am wondering what's the best way to have a central/or maintainable place for a mapping like:
an English label for field key 'valid_from' is 'Valid from'
To my understanding all Translatable extensions for Doctrine (like Gedmo Kpn etc.) are to translate content (e.g. 'category' = 'Product' in English and = 'Produkt' in German) but not schema.
And of course I cannot change/adapt the field key to the language because it's the identifier for the frontend.
What I thought so far:
Use some mapping file between field_key, language_key and
translation on frontend.
Issue here is that the frontend needs to know a lot and ideally any change in the API can be done thoroughly by the backend developers.
Use some mapping file between field_key, language_key and
translation on frontend.
As we use annotations for our Entity model and JSMSerializer I'd need to open a totally new space for just translation information. Doesn't sound too convincing.
Create custom annotation with properties
Current idea is to use custom annotation (which would be cacheable and could be gathered and provided as one JSON e.g. to the frontend) with my entity properties.
That means any backend developer could immediately check for translation keys at least as soon as the API changes.
Something like:
#ORM\Column(name='product', type='string')
#FieldNameTranslation([
['lng'=> 'de-DE'],['text']=>'Product'],
['lng'=> 'en-En'],['text']=>'Produkt'])
A further idea could be just to provide some translation key like:
#FieldNameTranslation(key='FIELD_PRODUCT')
and use Symfony's translation component and have the content in translation yml files.
What is your opinion? Is there any 'best in class' approach for this?

How to call REST service by setting Matrix Params using Camel-Http4 component?

I have a problem trying to use Camel-http4 component. What I want to do is to set from my camel route the Matrix Params that the REST service needs to work properly. Is there any way to do that?
Thank you,
Roxana
Using traditional query parameters, the Camel URI looks as follows:
from("direct:start")
.to("http4://oldhost?order=123&detail=short");
Thus, using matrix parameters should work as well:
from("direct:start")
.to("http4://oldhost;order=123;detail=short");
Edit:
Use Exchange.HTTP_URI for dynamically setting the properties or use recipientList such as:
from("direct:start")
.recipientList(simple("http4://oldhost;order=${header.123Header};detail={{value.from.cfg}}"));