// Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java
// public class JsonBuilderFactory {
//     public static JsonObjectBuilder object() {
//         return new JsonObjectBuilder();
//     }
// 
//     public static JsonArrayBuilder array() {
//         return new JsonArrayBuilder();
//     }
// }


import net.minidev.json.JSONArray;
import net.minidev.json.JSONObject;
import java.io.Serializable;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.stream.Collectors;
import javax.persistence.*;
import javax.validation.constraints.Size;
import org.springframework.hateoas.ResourceSupport;
import org.springframework.web.bind.annotation.ResponseBody;
import com.aemreunal.helper.json.JsonBuilderFactory;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
    @ManyToOne(targetEntity = Project.class,
            optional = false,
            fetch = FetchType.LAZY)
    @JoinTable(name = "projects_to_connections",
            joinColumns = @JoinColumn(name = "connection_id"),
            inverseJoinColumns = @JoinColumn(name = "project_id"))
    @Access(AccessType.PROPERTY)
    private Project project;
    /*
     * END: Connection 'project' attribute
     *------------------------------------------------------------
     */

    /*
     *------------------------------------------------------------
     * BEGIN: Helpers
     */
    public void addBeacon(Beacon beacon) {
        this.getBeacons().add(beacon);
    }

    public JSONArray getBeaconIdsAsJson() {
        return JsonBuilderFactory.array()
                                 .addAll(getBeacons().stream()
                                                     .map(Beacon::getBeaconId)
                                                     .collect(Collectors.toList()))
                                 .build();
    }

    public JSONObject getQueryResponse() {
// Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java
// public class JsonBuilderFactory {
//     public static JsonObjectBuilder object() {
//         return new JsonObjectBuilder();
//     }
// 
//     public static JsonArrayBuilder array() {
//         return new JsonArrayBuilder();
//     }
// }


// Path: src/main/java/com/aemreunal/domain/Connection.java
import net.minidev.json.JSONArray;
import net.minidev.json.JSONObject;
import java.io.Serializable;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.stream.Collectors;
import javax.persistence.*;
import javax.validation.constraints.Size;
import org.springframework.hateoas.ResourceSupport;
import org.springframework.web.bind.annotation.ResponseBody;
import com.aemreunal.helper.json.JsonBuilderFactory;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

    @ManyToOne(targetEntity = Project.class,
            optional = false,
            fetch = FetchType.LAZY)
    @JoinTable(name = "projects_to_connections",
            joinColumns = @JoinColumn(name = "connection_id"),
            inverseJoinColumns = @JoinColumn(name = "project_id"))
    @Access(AccessType.PROPERTY)
    private Project project;
    /*
     * END: Connection 'project' attribute
     *------------------------------------------------------------
     */

    /*
     *------------------------------------------------------------
     * BEGIN: Helpers
     */
    public void addBeacon(Beacon beacon) {
        this.getBeacons().add(beacon);
    }

    public JSONArray getBeaconIdsAsJson() {
        return JsonBuilderFactory.array()
                                 .addAll(getBeacons().stream()
                                                     .map(Beacon::getBeaconId)
                                                     .collect(Collectors.toList()))
                                 .build();
    }

    public JSONObject getQueryResponse() {
        return JsonBuilderFactory.object()