Posts

Showing posts from September, 2019

warning: LF will be replaced by CRLF in

Image
Problem :

The file will have its original line endings in your working directory







Solution:

step1) open .gitconfig file

step2) paste the below code


[core]
autocrlf = false
[filter "lfs"]
required = true
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process


Could not install from "@angular\cdk\scrolling" as it does not contain a package.json file

Image
Problem :
npm install  @angular/cdk/scrolling chart.js quill
command is failing

Error Logs:

npm ERR! code ENOLOCAL
npm ERR! Could not install from "@angular\cdk\scrolling" as it does not contain a package.json file.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\naresh\AppData\Roaming\npm-cache\_logs\2019-09-26T23_27_21_226Z-debug.log

C:\Users\naresh\2019-projects\food-app2>npm install --save @angular/cdk/scrolling chart.js quill
npm ERR! code ENOLOCAL
npm ERR! Could not install from "@angular\cdk\scrolling" as it does not contain a package.json file.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\naresh\AppData\Roaming\npm-cache\_logs\2019-09-26T23_27_49_903Z-debug.log

C:\Users\naresh\2019-projects\food-app2>npm install --save @angular/cdk/scrolling
npm ERR! code ENOLOCAL
npm ERR! Could not install from "@angular\cdk\scrolling" as it does not contain a package.json file.

npm ERR! A complete l…

jhipster find all records for admin and findByUserIsCurrentUser for current user

Problem :
Normal user should not fetch all the records in entity ,and admin user should be able to fetch the records.

Solution:

 public List<FoodItem> getAllFoodItems() {
        log.debug("REST request to get all FoodItems");
        if(SecurityUtils.getCurrentUserLogin().get().equalsIgnoreCase("admin"))
        {
return foodItemRepository.findAll();
        }
         return foodItemRepository.findByUserIsCurrentUser();

    }

Drop down menu with name instead of ID in Jhipster

Image
Problem:
how to list item name in drop down instead of ID.




Solution 1 :

In entity relationship use name field so that the value will appear directly in the drop down, for example in the below entity relationship food item name directly appear in the Menu entity instead of food item ID .

relationship OneToMany { FoodItem to Menu{fooditem(foodname)} Vendor to Menu{vendor(name)} Vendor to Order{vendor(name)} FoodItem to Order{fooditem(foodname)}}
Solution 2 :
Modify the entity html page remove ID and add field name which you want to show.
   <td>
                    <div *ngIf="vendor.menu">
                        <a [routerLink]="['../menu', vendor.menu?.id, 'view' ]" >{{vendor.menu?.id}}-{{vendor.menu?.foodname}}</a>
                    </div>
                </td>





Full entity relationship for reference. 

entity Vendor
{
name String required
}
entity Menu
entity FoodItem {
foodname String required ,
    cost Long…

nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: No _valueDeserializer assigned

Problem:

nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: No _valueDeserializer assigned


Solution:

Modifiy  POJO class as below

Before  :

@ManyToOne
    @JsonIgnoreProperties("orders")
    private Vendor vendor;

    @ManyToOne
    @JsonIgnoreProperties("orders")
    private Menu menu;

After :

@ManyToOne 
@JsonIgnoreProperties(value = {"orders"}, allowSetters = true)
    private Vendor vendor;

    @ManyToOne
@JsonIgnoreProperties(value = {"orders"}, allowSetters = true)
    private Menu menu;