display data based on LOV selection in adf - java

I have adf view Object called SalesVO that I need to save to database, in that View object I have a foreign key (CustomerId) that is associated with another View Object called CustmersVO
I dragged salesVO in jspx page, The user should enter information in the sales information in the page then click save (commit).
the problem is when while the user is filling the sales info he should select customer from LOV once he select customer the page should display Customer info (like address, phone, ..etc) automatically from CustomersVO
how can I display these read only info of the selected customer?
the structure is as follow:
SalesVO : saleId, SaleDate, CustomerId ..... etc
CustomerVO: CustomerId, CustomerName, Phone, Address....etc

Are you saying you want to basically join the Sales info with Customer info and allow user to select the Customer based on Customer ID in Sales VO and then when that customer is selected, display the retrieved customer data along with the sales VO, but only the Sales VO info is saved?
If so this is a simple, basic thing to do in ADF BC. have you looked at the many tutorials available online here? Have you read the docs on how to create an LOV or Reference entity usage or seen this or this?
The SalesVO is based on the Sales EO and is updatable, then add the CustVO as a non-updatable reference only data and then make the Cust ID in the Sales VO the basis for the LOV. The selected Customer data will appear in the LOV and the selected Customer ID will be saved as the foreign key to the Sales VO, with the extra customer data providing non-updatable reference values. The steps to do this are widely available in many blog posts - Google is your friend here. Also consider reading the ADF BC docs, on LOVS, and reference entities and joins of VOs.

Related

How can I delete rows in a database using a query?

There is a user with the attribute Role, by default TENANT, using a query we set him LANDLORD and in theHOUSE table he adds an apartment with various attributes: description, price, city_id and others. But suddenly this user wanted to remove himself from the status of LANDLORD, delete his apartments from our database and again become justTENANT, how in this case can I delete the information that he has apartments? How to do it, if he has apartments, then they need to be deleted, if not, then just change the user's status to TENANT?
At first there was an idea to assign a zero value, but it seemed strange to me if we just zeroed it out, because then the table will start to get cluttered. There is also a status option: ACTIVE or BANNED, but I don't like this option, because his apartment is still not needed.
The code looks like this:
#PutMapping ("/ {id}")
#PreAuthorize ("hasAuthority ('landlord: write')")
public void TenantPostAdd (#PathVariable (value = "id") Long id) {
User user = userRepository.findById (id) .orElseThrow ();
Role role = Role.TENANT;
user.setRole (role);
House house = houseRepository.findById (id) .orElseThrow ();
house ... // what's here
}
Full Code
To build this level of infrastructure, there are a lot of questions I would have to ask to recommend something. I'd want to see the current database schema as well. Your also requesting the ability to delete which can become problematic. You may want to consider leaving data if you believe that the customer may change roles again. That kind of information is based off of the terms of agreement.
Have you considered building something like this?
Absolute(Numeric) Mode
0 No Permission --- etc...
https://www.guru99.com/file-permissions.html
This could be a prepared statement issue with not the appropriate joins occurring in the statement. I believe you should take another look over your database schema.

how to get a search box using jhipster:import-jdl?

Lets say that we have a book and author entities in JDL-Studio like this:
entity Book {
name String required minlength(2)
}
entity Author {
name String required minlength(2)
}
relationship ManyToMany {
Book{author(name)} to Author{book}
}
When we run the show, we can login and create a new book, but we need to choose between the list of authors in the dropdown list that we have already created in the author entity, right?
How can we do this 2 things using jhipster:import-jdl:
1) tell Jhipster-JDL to create a search box to look in a list of authors (let's say we have a 1000 author entries) and
2) have a text box where we can add a new text creating a new author entry in the database (or think about a tag for the book: adventures, science-fiction,... but not using the already created from the list).
Is it posible to do that when creating de JDL-Studio Entities? Is there any place with more advanced use cases besides https://www.jhipster.tech/jdl/
Would it be possible with jhipster-uml? Is UML, more powerful? https://www.jhipster.tech/jhipster-uml/

ehcache search API - in case of joining two tables

i am trying to new cache configuration with new DB tables. following are sample table structure and sample Data.
TABLE_DEPT:
Dept Id Detp Name Dept Dtls
111 SALES A1
112 MARKET A2
TABLE_EMP:
Emp Id Emp Name DeptId Working Started Working ended
1 ABEmp 111 01-01-2017 02-02-2017
2 CDEmp 112 01-01-2017 03-12-2017
3 EFEmp 113 01-01-2017 03-12-2017
1 ABEmp 115 03-02-2017 03-12-2017
if i want to add load the data in cache by using Dept Id, i will have unique dept Id with list of emp Id - details.
if i want to search by dept id in ehcache configuration, i can simply give search attribute is "dept id".
but, if i want to search by emp id, i should get list of dept under employee worked.
what should be my ehcache design?
my Java bean/POJO looks like below.
Class DeptDtls{
int deptId;
String deptName;
List<Integer> empIdList;
//Setter & getters
}
cache - i want to put key as deptId & value is whole DeptDtls.
in this case, how can i allow search operation based on empId?
Ehcache can provide in memory data storage only but in your case search also required on top cache.I got the same scenario and used elasticsearch for caching the data and search on stored data.elastic search has inbuilt support for search and we can index the stored data .elasticsearch can be configured for cache.

Building a datastructure in Java

I am trying to construct a DTO object to ferry the data from data layer to view layer.
The data is as follows:
There are 7 days(dates can be used as a key in Map or any other datastructure)
The individual dates will contain multiple records.
Each record contains contact details obtained from multiple tables.
One record needs to be constructed from 3 rows in the result table. ie:
A record may return three rows with same values for all columns except for the user details; which contains details like id,name and designation.
When I display, I need to show their name as Manager and assistant manager in the same row.
Data Layer
T01 25/12/2012 ABC XYZ Manager
T01 25/12/2012 ABC IJK Asst.manager
Display:
Date 1
TaskID Taskdeadline TaskGivenBy Task assigned to Manager Task Assigned toAsst.Manager
T01 25/12/2012 ABC XYZ IJK
T02 1/1/2013 BCE WUV MNO
Solution I tried:
Map<Date,Map<Position,Object>>
Map<25/12/2012,Map<(Manager,Object details),(Asst Manager,Object details)>
and then repeat it. But I guess I am storing duplicate data. I don't think this is an ideal solution

storing a shopping cart when no user is logged in(playframework doubt)

I was browsing through posts about Play! framework and came across some posts which discussed ecommerce.Since I am a beginner to both,I thought of doing an exercise.I wrote down some use cases and some requirements as below.I would like to hear your opinion about it,hoping it may broaden my technical wisdom.
Some requirements for shopping cart on a webpage:
1.User can add items to cart even without logging in to the site.
2.User need to login after he clicks on checkout link.
3.Itemdetails page will contain an addtocart button only if that item is not already in the cart.
4.Itemdetails page will contain a minicartview ,showing names of items in cart and total price.
I coded the ShoppingCart as below.It can be retrieved from db using it's User.
#Entity
class ShoppingCart{
...
#OneToOne
public User user;
}
Some possible scenarios I considered.
1.User is already logged in ,when he comes to the Itemdetails page.
This seems easy,I can retrieve the cart from db,using the logged in user.
User user = User.find("byEmail", Security.connected()).first();
cart = ShoppingCart.find("byUser",user);
...
2.No user logged in at present.
This is what bothers me.How to handle this?How can I show the minicartview here on Itemdetails page?Where should I store the cart?Cache is volatile and cannot be trusted .How else should I store the cart?I cannot store in db until a user logs in.
If someone can make things clear about this scenario,it may help me a lot..
You have a few options. You could
Store the shopping cart items in your session (as it is a cookie, try to limit the amount you store). When the user logs in, you can then merge your session shopping cart items with their logged in user items. As with sites, such as Amazon, it would make sense to try to store a long-live session on the user's computer to remember the id of the logged in user for later usage.
Store the data in a database against a temporary username. This would act much like the session, but you would have to have a regular job that would clear down the temporary users database table if it is not converted to a full user.
Personally, I would go for option 1. It is fairly simple to implement, there is nothing personal in the cookie (as it is just IDs), and it is meant as a short term storage.
The way you are modeling this a user can have only one cart. You should create a cart for each session instead. Use session id as primary key for the cart entity and do not associate with User.
also see: advice on implementing a shopping cart using playframework

Categories

Resources