In JPA specification Predicate is there any way to check while retrieving from DB whether the username is in email format or not - spring-data-jpa

My Objective is to List user only when username is in emailformat in DB .I am using JPA specification to get complete list . Let me know how to get the list which having username in email format .
I have written JPA specification to get complete list . Stuck how to get List containing only those which having username as email format

Related

Using Logic Apps, how can I input a formatted Table of results from an SQL Stored Procedure into SendGrid Email

Once a day, I need to run an SQL Stored Procedure, which collects a list of results. I then need to input the results, as a nice user friendly table, into an e-mail (SendGrid).
So far, I have setup all connections and got the Logic App to work but the e-mail it generates displays the results like this:
{"Table1":[{"CaseID":"1000001","DateOfUdate":"2020-06-09T11:34:57.483"},{"CaseID":"1000002","DateOfUdate":"2020-06-09T11:34:57.483"},{"CaseID":"1000003","DateOfUdate":"2020-06-09T11:34:57.483"},{"CaseID":"1000004","DateOfUdate":"2020-06-09T11:34:57.483"}]}
How can I get this to be displayed as a proper table?
Case ID DateofUpdate
1000001 2020-06-09T11:34:57.483
1000002 2020-06-09T11:34:57.483
1000003 2020-06-09T11:34:57.483
1000004 2020-06-09T11:34:57.483
Below are images of my Logic App - please let me know if I need to provide more information.
For this requirement, please refer to the steps I provided below:
1. I initialize a variable named "resultSetVar" and store the json data same to yours', use this variable to simulate your "ResultSets" data.
2. Then use "Parse JSON" action to parse the json data.
3. After that, use "Create HTML table" action to create the html with the json array "Table1" from the "Parse JSON" action.
4. At last, put the "Output" from "Create HTML table" action into the "Email body" box.
5. Running the logic app, I received the email shown as below
Hope it helps~

How to use Moodle REST API Call mod_data_add_entry (and parameters)?

I'm trying to set up a webpage that communicates with a Moodle page. I need different data from a database activity and want to create new entries. Note that I am not talking about the SQL database in BG, it is the activity database in courses.
The information should be retrieved/transferred via the REST API, an HTML POST Request. My problem is that I don't know how to add a new record to the database activity because I cannot transfer the data array. Only the first parameter given appears in my database.
E.g. i tried ...&wsfunction=mod_data_add_entry&databaseid=10&data[0][fieldid]=66&data[0][value]=12&data[1][fieldid]=67&data[1][value]=test
And many other combinations. Always only the first parameter is shown in the database.
The docs tell me this (Pseudocode):
//The fields data to be created
list of (
object {
fieldid int //The field id.
subfield string Default to "" //The subfield name (if required).
value string //The contents for the field always JSON encoded.
}
)
Alternatively:
REST (POST parameters)
data[0][fieldid]= int
data[0][subfield]= string
data[0][value]= string
I cannot find anywhere else something called a "subfield".
Any ideas?
Okay, found it. You have to put your values in "", unless they are not a number. Seems like there is a connection with this special activity because you don't have to do it elsewhere.

REST API parameter with multiple value types

I have the API route /api/users/:user_id, which takes a number as a parameter.
I want to have now the same route, but taking the username instead of the id, like this: /api/users/:username.
In my code, I have the route set up as /api/users/:user and I check the user URI parameter and do different actions if it is a number or a string.
Is it good practice / efficient to have the same route, but with a different parameter type? Both the username and user id's are unique.
It works, I just want to know if this is a practical solution, or if I should do separate routes.
we solved it by parsing the path variable.
psuedo code
long id;
String name;
try{
id = parselong(input);
}catch(parse exception){
name = input;
}
findbynameorid(id,name)
select * from customer where name = ? or id = ?
Assuming that both IDs and usernames are unique, it's valid solution.
Regarding implementation, you could use a regular expression to match the user identifier and check if it's an ID or a username.
It isn't really "good practice" to share a route parameter on a route, but as long as the IDs and usernames are both unique, you should be fine. Both act as unique identifiers for a user so both can be used to find the user in that route.
You can accept both the ID and username as the same parameter by first making the route param more permissive. Next, you can use the following (pseudo) query to look up whether that param matches the ID or the username:
SELECT id, name FROM users WHERE id={param} OR username={param}
Remember to pass that param in as a real query parameter; do NOT simply concatenate strings. Doing so will open you up to an SQL injection attack.
Solution
Make Parameter value as string and send one Request parameter as additional flag which describe request mode.
/api/users/:user_key?type=boolean > true(default) userid & false for username or vice versa.
Modify your api which then can answer two different apis
/api/users/user/userid/:id & /api/users/user/username/:name
Recommended
Above can resolve your issue. But is not recommended way of dealing with fetching user profile information using REST api. Presuming you will introduced user authentication in you rest application.
Self api : /api/users/me : this will fetch user info of the once who is currently logged with respect to that session/token.
User api : api/users/:id : this will fetch fetch specific user info
Username api: api/users?filters={username=some_username, }: this will fetch info of those users which have username matching with given filter.

Parse dashboard - objectId must be a string: ObjectIdHex("56eac5ea1ac8242012ae4ed9")

Recently i migrated all my parse data to MongoLab. i'm saving documents (parse object) directly to mongoDb using MongoClient.save(...), and not using parse SDK.
now mongo generate auto id, in my case - '56eac5ea1ac8242012ae4ed9', and parse dashboard not show any row in this class till i delete this object (document) and i'm getting the next error: objectId must be a string: ObjectIdHex("56eac5ea1ac8242012ae4ed9")
should i save id differently?
how to convert my id to regular Parse object id? (if i reallty need it?)
any solution?
I know parse dashboard is temporary, but right now it helps
It occurs because by default Mongo create an ObjectId for each object stored in its collections. To overcome it, you have to order Mongo store your own generated Id.
You can do it by sending the _id property in your object that is being stored in Mongo. Something like this:
db.collection('_User').save({_id: yourid, ...})
You can generate any random string id, but it would be good to generate the _id as the same way Parse Server does. If you check Parse Server repository (https://github.com/ParsePlatform/parse-server/blob/master/src/cryptoUtils.js) you can find how the id is generated.
Anyway. There are solutions, like www.back4app.com, that already provides full hosting of both parse server, parse dashboard and database
--
Disclosure: I am founder of back4app.com

woocommerce customer Fetch with time filter

I am requesting customer data using Rest Api of woocommerce. Woocommerce api documentation says
"All endpoints (except for customer orders) support date filtering via created_at_min and created_at_max as ?filter[] parameters. e.g. ?filter[created_at_min]=2013-12-01".
However, when I am giving date filter in request URL it results in blank response!!
My question is,can the customer data be fetched via date filter in woocommerce.
Thanks.
You can pass Filter with time in REST API of WooCommerce.
Just pass the filter in H:i:s format.
Note : while trying to generate the signature, I found, the URL encoding needs to be done twice because of extra space between DateTime filter criteria. Just encode the clean text once to get RFC3986 encoding, and do it again to generate the signature. Pass the first encoded string and append the generated signature. I saw the filter to be working.