Spring JPA With mongo Supporting Contains and LessThan - spring

I am using Spring JPA with mongo.I have a requirement to use contains query on one of the fields.If end users(UI/Service) hits the GET Request and looks for information in EMAIL Field,I need to search based on text.Pretty much it is like.
https://docs.spring.io/spring-data/jpa/docs/current/reference/html/
This link explains that We can Use Contains to get the Data.
List<ScheduledNotification> findByMobileNumberContaining(String mobileNumber);
List<ScheduledNotification> findByEmailIdIgnoreCaseContaining(String emailId);
But when I am using this API,I am not able to get the data.So ,has any one done something like using Contains.

well ,I was not sending content type in header attribute in GET request.So yes it works,alright.There was no issue with method signature.

Related

Google Cloud Document AI processing response impossible to get Form Fields in PHP

I cannot get form fields values from processing a response in PHP when using a Google Cloud Document AI with a custom processor where the form fields are defined. google-cloud only has documentation for Java, C#, Pyton... How can I get my data? When I tested it in googe-cloud then everything worked...
I try to looping over pages en so trying to get formFields but nothing works.
Custom Document Extractor returns the extracted data in the entities field, not formFields.
The Form Parser Processor is currently the only processor that populates the formFields field.
You can use this example to follow the logic for how to handle the response for Entity Extraction processors.
https://cloud.google.com/document-ai/docs/handle-response#entities_nested_entities_and_normalized_values

Create Spring Boot microservice that accepts a given Json?

So the question: i have the following Json:
{
"type": "ipv4",
"value": "1.2.3.4",
"firstSeen": "2020-07-10 15:00:00.000",
"totalCount": 8
}
i need to create a spring boot microservice from it ,with the following restrictions:
TotalCount cannot be less than 0 and cannot be more than 100.
firstSeen date should ALWAYS be converted to ISO 8601 format. The user can enter the date
in any string format. Return error if it is not well formed.
Expose the following RESTful APIs
Create a new record (as shown above, id auto-generated)
Get record by value
as this is my first time working with microservice,i can not understand this problem,is there anyone can help me with this please?
You will need to create a basic Spring Boot project using Spring Initializer, if you are using Intellij you can use this link as reference https://www.jetbrains.com/help/idea/your-first-spring-application.html#create-new-spring-boot-project.
Then add a new controller method which accepts a Json Request. Since you are trying to create a new record, I suggest you use POST method. Json Request will accept the 4 input parameters you mentioned. This is very basic and you should be able to find it in pretty much any Spring boot tutorial online. you can refer for example https://dzone.com/articles/simple-spring-boot-post
This Json Request can have validator annotations which check for the criteria you give. For example you can have #Size(min=0, max=100, message="TotalCount cannot be less than 0 and cannot be more than 100"). https://www.baeldung.com/jpa-size-length-column-differences
For date you might need to write a custom validator to check the specific format you want. For creating a record I guess you mean adding it to database. here you can configure your database using the yaml file, again there are lot of online resources on how to configure a Database in your spring boot project. https://blog.tericcabrel.com/write-custom-validator-for-body-request-in-spring-boot/
Since its your first time, it might take a while to figure out various details but I assure you once you get a hold of it, its going to be easy.

Get full URL with parameters in Thymeleaf?

I've got a paginated list of cars, on a Spring Boot server, with the parameters sort, range, desc, page, etc to filter and sort by and am generating the URL in Thymeleaf that looks like:
example.com/cars?page=5&sort=mileage
I am wanting to be able to add more parameters to a URL with a few of these already but I'm quite new to this and don't really know how to get the current URL with all the parameters to add more params without losing the previous ones look like
example.com/cars?page=5&sort=mileage&desc=true
I've found an answer to do something like this on Spring but would ideally want to do it on the Thymeleaf template, is this possible?
Get full current url thymeleaf with all parameters
I found that you can get hold of specific parameters in Thymeleaf using ${param.sort} to get hold of the param sort, could something similar to this get hold of all the params currently?
Thanks
If someone is still looking for a thymeleaf template only solution, you could use ${#request.getRequestURI()} with ${#request.getQueryString()} and add your additional parameters via concatenation:
<a th:href="#{${url}}" th:with="url=${#request.getRequestURI()+'?'+#request.getQueryString()+'&foo=bar'}">Link</a>
If you need to escape query parameters, you can use #uris.escapeQueryParam():
<a th:href="#{${url}}" th:with="url=${#request.getRequestURI()+'?'+#request.getQueryString()+'&foo='+#uris.escapeQueryParam('b a r')}">Link</a>
Some further details:
You have to use th:with, otherwise the parser will throw TemplateProcessingException: Access to request parameters is forbidden in this context. in newer thymeleaf versions.
It also works when the current query is empty, the url generator will create a valid url, in my example including one ? and no & in the query part.

How to update the "Replacement Value" in ReplaceText Processor using Rest API?

I need to know how to update the values in nifi processors using Rest API.
https://nifi.apache.org/docs/nifi-docs/rest-api/index.html
For example: I have used below processor structure
GetFile>SplitText>ExtractText>ReplaceText>ConvertJSONToSQL>PUTSQL.
I have passed following inputs for above processors.,
FileLocation(GetFile).
validation(ExtractText).
ReplacementValue(ReplaceText).
DBCP ConnectionPool,username and pwd for SQL.
I just need to use nifi rest api client to write above inputs into processors.
For example : If I give Processor name and input file in Rest API Client then it will write into processor.
Please stop me if anything i'm doing wrong.
Help Appreciated and Tell me any other ways is possible?
Mahen,
You can issue a PUT request to /processors/{id} and provide the new value of the "Replacement Value" property. You'll need to provide JSON body in the request to do this, and you can see the structure by expanding the endpoint noted above on the documentation link you provided, then clicking ProcessorEntity > ProcessorDTO > ProcessorConfigDTO to see the pop-up dialogs with the element listing and examples. You can also quickly get the current values of the processor by issuing a GET request to /processors/{id}.

How can I use Parse to send data to specific user

I'm creating an online game which have to send data between users. I chose Parse as the backend service. How can I use Parse to do this task?
Query for the user that you want to send data to and send data
Take a look a the Parse Docs. What you want to do is documented very well there.
https://parse.com/docs/android_guide
Take a look at saving and retrieving objects.
Also make sure your console (where you can see the "User" class and all your other classes) is set up with the objects you need.

Resources