Question

In: Computer Science

Can anyone implement RestApi(CRUD) for this using Spring boot and Firebase? I will appreciate it farms:...

Can anyone implement RestApi(CRUD) for this using Spring boot and Firebase? I will appreciate it

farms: [

{

id: string,

farmer: string,

name: string,

image: reference,

description: string,

location: string,

geoLocation: geopoint,

rating: number

}

]

(subcollection within a farm document) products: [

{

id: string,

name: string,

image: reference,

quantity: number,

description: string,

price: number,

expirationDate: timestamp,

updatedDate: timestamp,

categories: array[string],

tags: array[string],

location: string,

geoLocation: geopoint,

rating: number

}

]

Solutions

Expert Solution

Here you can go setp by setps ::

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
public class Application  {

    public static void main(String[] args) {
        SpringApplication springApplication = new SpringApplication(Application.class);
        springApplication.addListeners(new ApplicationPidFileWriter());
        springApplication.run(args);
    }
}


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class InputController {

 @PostMapping(value = "/greeting",produces= MediaType.APPLICATION_JSON_VALUE,consumes=MediaType.APPLICATION_JSON_VALUE)
    public boolean indexCreator(@RequestBody  InputClass input) throws IOException {
        System.out.println(input[0].getF());
                 System.out.println(input[0].getP());
        
        return true;
    }
}

        
import java.util.List;

class InputClass {
    private List<Farms> f;
    private  List<Products> p;

    public InputClass(List<Farms> f, List<Products> p) {
        this.f = f;
        this.p = p;
    }

    public List<Farms> getF() {
        return f;
    }

    public void setF(List<Farms> f) {
        this.f = f;
    }

    public List<Products> getP() {
        return p;
    }

    public void setP(List<Products> p) {
        this.p = p;
    }
}
import org.apache.lucene.spatial3d.geom.GeoPoint;

import javax.naming.Reference;

public class Farms {
    private  int id;
    private  String farmer;
    private  String name;
    private Reference image;
    private  String description;
    private  String location;
    private GeoPoint geolocation;
    private  String rating;

    public Farms(int id, String farmer, String name, Reference image, String description, String location, GeoPoint geolocation, String rating) {
        this.id = id;
        this.farmer = farmer;
        this.name = name;
        this.image = image;
        this.description = description;
        this.location = location;
        this.geolocation = geolocation;
        this.rating = rating;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getFarmer() {
        return farmer;
    }

    public void setFarmer(String farmer) {
        this.farmer = farmer;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Reference getImage() {
        return image;
    }

    public void setImage(Reference image) {
        this.image = image;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getLocation() {
        return location;
    }

    public void setLocation(String location) {
        this.location = location;
    }

    public GeoPoint getGeolocation() {
        return geolocation;
    }

    public void setGeolocation(GeoPoint geolocation) {
        this.geolocation = geolocation;
    }

    public String getRating() {
        return rating;
    }

    public void setRating(String rating) {
        this.rating = rating;
    }
}
import org.apache.lucene.spatial3d.geom.GeoPoint;

import java.lang.ref.Reference;
import java.sql.Timestamp;

public class Products {
    private String id;
    private  String name;
   private Reference image;
   private  int quantity;
   private  String description;
   private int price;
   private Timestamp expirationDate;

    private Timestamp updatedDate;
   private String[] categories;
   private  String[] tags;
   private  String location;
   private GeoPoint geoLocation;
   private int rating;

    public Products(String id, String name, Reference image, int quantity, String description, int price, Timestamp expirationDate, Timestamp updatedDate, String[] categories, String[] tags, String location, GeoPoint geoLocation, int rating) {
        this.id = id;
        this.name = name;
        this.image = image;
        this.quantity = quantity;
        this.description = description;
        this.price = price;
        this.expirationDate = expirationDate;
        this.updatedDate = updatedDate;
        this.categories = categories;
        this.tags = tags;
        this.location = location;
        this.geoLocation = geoLocation;
        this.rating = rating;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Reference getImage() {
        return image;
    }

    public void setImage(Reference image) {
        this.image = image;
    }

    public int getQuantity() {
        return quantity;
    }

    public void setQuantity(int quantity) {
        this.quantity = quantity;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public int getPrice() {
        return price;
    }

    public void setPrice(int price) {
        this.price = price;
    }

    public Timestamp getExpirationDate() {
        return expirationDate;
    }

    public void setExpirationDate(Timestamp expirationDate) {
        this.expirationDate = expirationDate;
    }

    public Timestamp getUpdatedDate() {
        return updatedDate;
    }

    public void setUpdatedDate(Timestamp updatedDate) {
        this.updatedDate = updatedDate;
    }

    public String[] getCategories() {
        return categories;
    }

    public void setCategories(String[] categories) {
        this.categories = categories;
    }

    public String[] getTags() {
        return tags;
    }

    public void setTags(String[] tags) {
        this.tags = tags;
    }

    public String getLocation() {
        return location;
    }

    public void setLocation(String location) {
        this.location = location;
    }

    public GeoPoint getGeoLocation() {
        return geoLocation;
    }

    public void setGeoLocation(GeoPoint geoLocation) {
        this.geoLocation = geoLocation;
    }

    public int getRating() {
        return rating;
    }

    public void setRating(int rating) {
        this.rating = rating;
    }
}

Here Now This will accept Rest Call :

/greeting

{

farms: [

{

id: string,

farmer: string,

name: string,

image: reference,

description: string,

location: string,

geoLocation: geopoint,

rating: number

}

]

products: [

{

id: string,

name: string,

image: reference,

quantity: number,

description: string,

price: number,

expirationDate: timestamp,

updatedDate: timestamp,

categories: array[string],

tags: array[string],

location: string,

geoLocation: geopoint,

rating: number

}

]

}


Related Solutions

If anyone can show me how these are solved I would appreciate it, answers included though...
If anyone can show me how these are solved I would appreciate it, answers included though please. 16.) Which of the follow conatin the GREATEST number of MOLES of OXYGEN. Show your work. 0.50 mol P4010, 1.5mol P2O5, 2.5mol CO2, 2.0mol N2O4    20.) Ibuprofen has a chemical formula C13H1802. When the equation is properly balanced what is a correct mole ratio of CO2 to H2O in the reaction? 21.) 4Al(s) + 3O2(g) ---> 2 Al2O3 (s) If 10.0 mol...
If anyone can "dumb this down for me I'd appreciate it. I'm really not good with...
If anyone can "dumb this down for me I'd appreciate it. I'm really not good with statistics, I'm easily confused by all the terms and symbols so if someone is willing to explain a basic easy to understand example that would be much appreciated- What types of misconceptions and errors do your foresee occurring in a business setting if the normal distribution assumptions are not applied correctly? Please include a real-world business example in your response.
Could anyone please explain how to do this? I would appreciate it! The judges of County...
Could anyone please explain how to do this? I would appreciate it! The judges of County X try thousands of cases per year. Although in a big majority of the cases disposed the verdict stands as rendered, some cases are appealed. Of those appealed, some are reversed. Because appeals are often made as a result of mistakes by the judges, you want to determine which judges are doing a good job and which ones are making too many mistakes. The...
I appreciate your explanation. I found different answers on these questions and it can be confusing....
I appreciate your explanation. I found different answers on these questions and it can be confusing. 7. For a beneficiary to receive a qualified distribution from a Roth IRA, who must meet the five-year requirement? A. The beneficiary, after taking distributions. B. Both the owner and the beneficiary. C. Either the owner or the beneficiary, before taking distributions. 8. Which statement about the American Opportunity Tax Credit and the lifetime learning credit is FALSE? A. A portion of the American...
Summary Develop a Spring Boot Web App which allows user to create a list of the...
Summary Develop a Spring Boot Web App which allows user to create a list of the destinations they have visited during vacations. Your application should allow user to search for a destination based on year of visit. Form View The initial page should have links to either search for a destination , add a new destination, display a list of all destinations that they have visited. The search destination page will have a text field to search by year. The...
Can anyone explain to me how I solve this, I need to prepare a journal entry...
Can anyone explain to me how I solve this, I need to prepare a journal entry for the given problem: on jan 1 a corporation issued $325,000, 5.5%, 9 year bonds when the market rate was 6%. Interest is to be paid annually on each Jan 1
(JAVA) I was wondering if anyone can check if I am implementing this method correctly based...
(JAVA) I was wondering if anyone can check if I am implementing this method correctly based on the instructions? Here are the instructions: buildShape(String input) In the buildShape() method, you will parse the provided input to determine whether to create a CircleShape or SquareShape. Before you create the shape, you need to determine it's size, location and color. Use TestableRandom to randomly generate an int size ranging from 100-200. Randomly generate an x and y index for its location. X...
Can anyone explain the structure and complex of Fatty Acid synthase I? I know the purpose...
Can anyone explain the structure and complex of Fatty Acid synthase I? I know the purpose of the enzyme, I just need a good explanation of how it works and moves the growing chain around the complex.
How do I solve short-term load forecasting using Multiple Linear Regression? Can anyone provide me a...
How do I solve short-term load forecasting using Multiple Linear Regression? Can anyone provide me a step by step solution with a sample data?
How do I solve short term load forecasting using Multiple Linear Regression? Can anyone provide me...
How do I solve short term load forecasting using Multiple Linear Regression? Can anyone provide me a step by step guide and solution? (Please provide a sample data)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT