Skip to content

Commit

Permalink
#116 added filter functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
elYanuki committed Sep 21, 2024
1 parent 2683a8e commit be31695
Show file tree
Hide file tree
Showing 55 changed files with 416 additions and 138 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import at.camconnect.dtos.deviceType.DeviceTypeFullDTO;
import at.camconnect.dtos.deviceType.DeviceTypeGlobalIdDTO;
import at.camconnect.dtos.deviceType.DeviceTypeMinimalDTO;
import at.camconnect.dtos.filters.DeviceTypeFilters;
import at.camconnect.responseSystem.CCException;
import at.camconnect.responseSystem.CCResponse;
import at.camconnect.enums.DeviceTypeVariantEnum;
Expand All @@ -19,6 +20,7 @@
import org.jboss.resteasy.reactive.RestForm;

import java.io.File;
import java.time.LocalDateTime;
import java.util.List;

@Path("/devicetype")
Expand Down Expand Up @@ -56,17 +58,19 @@ public Response getAll(){
return CCResponse.ok(result);
}

@GET
@POST
@Path("/getallfull")
@Transactional
public Response getAllFull(){
public Response getAllFull(DeviceTypeFilters deviceTypeFilters){
System.out.println("Reached getAllFull Endpoint at " + LocalDateTime.now());
List<DeviceTypeFullDTO> result;
try{
result = deviceTypeRepository.getAllFull();
result = deviceTypeRepository.getAllFull(deviceTypeFilters);
}catch (CCException ex){
return CCResponse.error(ex);
}

System.out.println("Sending data from getAllFull Endpoint at " + LocalDateTime.now());
return CCResponse.ok(result);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@

import java.util.List;

public record DeviceTypeAttributeCollection(List<CameraResolution> cameraResolutions, List<CameraSensor> cameraSensors, List<CameraSystem> cameraSystems, List<LensMount> lensMounts, List<TripodHead> tripodHeads) {
public record DeviceTypeAttributeCollection(List<CameraResolution> cameraResolutions, List<CameraSystem> cameraSystems, List<LensMount> lensMounts, List<TripodHead> tripodHeads, List<AudioConnector> audioConnectors) {
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package at.camconnect.dtos.filters;

import at.camconnect.enums.DeviceTypeVariantEnum;
import at.camconnect.enums.filters.OrderByFilterDevice;

import java.util.List;

public record DeviceTypeFilters(
boolean onlyAvailable,
List<DeviceTypeVariantEnum> variants,
List<Long> attributes,
List<Long> tags
) { }
3 changes: 3 additions & 0 deletions backend/src/main/java/at/camconnect/model/DeviceType.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import jakarta.persistence.*;

import java.time.LocalDateTime;
import java.util.List;

@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
Expand Down Expand Up @@ -61,6 +62,8 @@ public void updateChangeDate(){

public abstract DeviceTypeGlobalIdDTO toGlobalDTO();

public abstract List<DeviceTypeAttribute> getAttributes();

//getter setter

public DeviceTypeStatusEnum getStatus() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
import at.camconnect.dtos.deviceType.DeviceTypeGlobalObjectsDTO;
import at.camconnect.enums.DeviceTypeVariantEnum;
import at.camconnect.model.DeviceType;
import at.camconnect.model.DeviceTypeAttribute;
import at.camconnect.model.DeviceTypeAttributes.AudioConnector;
import jakarta.persistence.Entity;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;

import java.util.List;

@Entity
public class AudioType extends DeviceType {
@ManyToOne
Expand Down Expand Up @@ -44,4 +47,9 @@ public void update(DeviceTypeGlobalObjectsDTO data) {
public DeviceTypeGlobalIdDTO toGlobalDTO() {
return null;
}

@Override
public List<DeviceTypeAttribute> getAttributes() {
return List.of(connector);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import at.camconnect.enums.DeviceTypeStatusEnum;
import at.camconnect.enums.DeviceTypeVariantEnum;
import at.camconnect.model.DeviceType;
import at.camconnect.model.DeviceTypeAttribute;
import at.camconnect.model.DeviceTypeAttributes.CameraResolution;
import at.camconnect.model.DeviceTypeAttributes.CameraSensor;
import at.camconnect.model.DeviceTypeAttributes.CameraSystem;
Expand All @@ -14,6 +15,8 @@
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;

import java.util.List;

@Entity
public class CameraType extends DeviceType {
@ManyToOne
Expand Down Expand Up @@ -60,6 +63,11 @@ public DeviceTypeGlobalIdDTO toGlobalDTO() {
return null;
}

@Override
public List<DeviceTypeAttribute> getAttributes() {
return List.of(mount, system, photo_resolution);
}

public LensMount getMount() {
return mount;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
import at.camconnect.enums.DeviceTypeVariantEnum;
import at.camconnect.dtos.deviceType.DeviceTypeGlobalObjectsDTO;
import at.camconnect.model.DeviceType;
import at.camconnect.model.DeviceTypeAttribute;
import at.camconnect.responseSystem.CCException;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;

import java.util.List;

@Entity
public class DroneType extends DeviceType {
@Column(length = 5)
Expand Down Expand Up @@ -51,6 +54,11 @@ public DeviceTypeGlobalIdDTO toGlobalDTO() {
return null;
}

@Override
public List<DeviceTypeAttribute> getAttributes() {
return List.of();
}

public boolean isRequires_license() {
return requires_license;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
import at.camconnect.dtos.deviceType.DeviceTypeGlobalObjectsDTO;
import at.camconnect.enums.DeviceTypeVariantEnum;
import at.camconnect.model.DeviceType;
import at.camconnect.model.DeviceTypeAttribute;
import at.camconnect.model.DeviceTypeAttributes.LensMount;
import at.camconnect.responseSystem.CCException;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;

import java.util.List;

@Entity
public class LensType extends DeviceType {
@ManyToOne
Expand Down Expand Up @@ -56,6 +59,11 @@ public DeviceTypeGlobalIdDTO toGlobalDTO() {
return new DeviceTypeGlobalIdDTO(getType_id(), getName(), getImage_blob(), getF_stop(), getFocal_length(), getLens_mount().getAttribute_id());
}

@Override
public List<DeviceTypeAttribute> getAttributes() {
return List.of(lens_mount);
}

//region getter setter
public String getF_stop() {
return f_stop;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
import at.camconnect.dtos.deviceType.DeviceTypeGlobalObjectsDTO;
import at.camconnect.enums.DeviceTypeVariantEnum;
import at.camconnect.model.DeviceType;
import at.camconnect.model.DeviceTypeAttribute;
import at.camconnect.responseSystem.CCException;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;

import java.util.List;

@Entity
public class LightType extends DeviceType {
@Column(length = 6)
Expand Down Expand Up @@ -51,6 +54,11 @@ public DeviceTypeGlobalIdDTO toGlobalDTO() {
return new DeviceTypeGlobalIdDTO(getType_id(), getName(), getImage_blob(), isRgb(), isVariable_temperature(), getWatts());
}

@Override
public List<DeviceTypeAttribute> getAttributes() {
return List.of();
}

public int getWatts() {
return watts;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
import at.camconnect.dtos.deviceType.DeviceTypeGlobalObjectsDTO;
import at.camconnect.enums.DeviceTypeVariantEnum;
import at.camconnect.model.DeviceType;
import at.camconnect.model.DeviceTypeAttribute;
import at.camconnect.model.DeviceTypeAttributes.AudioConnector;
import at.camconnect.responseSystem.CCException;
import jakarta.persistence.Entity;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;

import java.util.List;

@Entity
public class MicrophoneType extends DeviceType {
private boolean needs_recorder;
Expand Down Expand Up @@ -51,6 +54,11 @@ public DeviceTypeGlobalIdDTO toGlobalDTO() {
return null;
}

@Override
public List<DeviceTypeAttribute> getAttributes() {
return List.of(this.connector);
}

public boolean isNeeds_recorder() {
return needs_recorder;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
import at.camconnect.dtos.deviceType.DeviceTypeGlobalObjectsDTO;
import at.camconnect.enums.DeviceTypeVariantEnum;
import at.camconnect.model.DeviceType;
import at.camconnect.model.DeviceTypeAttribute;
import at.camconnect.responseSystem.CCException;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;

import java.util.List;

@Entity
public class SimpleType extends DeviceType {
@Column(length = 150)
Expand Down Expand Up @@ -42,6 +45,11 @@ public DeviceTypeGlobalIdDTO toGlobalDTO() {
return new DeviceTypeGlobalIdDTO(getType_id(), getName(), getDescription(), getImage_blob());
}

@Override
public List<DeviceTypeAttribute> getAttributes() {
return List.of();
}

public String getDescription() {
return description;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
import at.camconnect.enums.DeviceTypeStatusEnum;
import at.camconnect.enums.DeviceTypeVariantEnum;
import at.camconnect.model.DeviceType;
import at.camconnect.model.DeviceTypeAttribute;
import at.camconnect.responseSystem.CCException;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;

import java.util.List;

@Entity
public class StabilizerType extends DeviceType {
@Column(length = 6)
Expand Down Expand Up @@ -47,6 +50,11 @@ public DeviceTypeGlobalIdDTO toGlobalDTO() {
return null;
}

@Override
public List<DeviceTypeAttribute> getAttributes() {
return List.of();
}

public double getMax_weight_kilograms() {
return max_weight_kilograms;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
import at.camconnect.dtos.deviceType.DeviceTypeGlobalObjectsDTO;
import at.camconnect.enums.DeviceTypeVariantEnum;
import at.camconnect.model.DeviceType;
import at.camconnect.model.DeviceTypeAttribute;
import at.camconnect.model.DeviceTypeAttributes.TripodHead;
import at.camconnect.responseSystem.CCException;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;

import java.util.List;

@Entity
public class TripodType extends DeviceType {
@ManyToOne
Expand Down Expand Up @@ -39,6 +42,11 @@ public DeviceTypeGlobalIdDTO toGlobalDTO() {
return new DeviceTypeGlobalIdDTO(getType_id(), getName(), getImage_blob(), getHeight_centimeters(), getHead().getAttribute_id());
}

@Override
public List<DeviceTypeAttribute> getAttributes() {
return List.of(head);
}

public TripodType() {
super();
setVariant(DeviceTypeVariantEnum.tripod);
Expand Down
4 changes: 2 additions & 2 deletions backend/src/main/java/at/camconnect/model/Tag.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class Tag {
@Column(length = 4)
private Long tag_id;

@OneToMany(fetch = FetchType.EAGER)
@ManyToMany(fetch = FetchType.EAGER)
private List<DeviceType> types;

@Column(length = 20, unique = true)
Expand All @@ -28,7 +28,7 @@ public Tag(String name, String description) {
public Tag() {
}

public long getTag_id() {
public Long getTag_id() {
return tag_id;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ public void remove(Long id){

public DeviceTypeAttributeCollection getAll(){
List<CameraResolution> cameraResolutions = em.createQuery("SELECT d FROM CameraResolution d", CameraResolution.class).getResultList();
List<CameraSensor> cameraSensors = em.createQuery("SELECT d FROM CameraSensor d", CameraSensor.class).getResultList();
List<CameraSystem> cameraSystems = em.createQuery("SELECT d FROM CameraSystem d", CameraSystem.class).getResultList();
List<LensMount> lensMounts = em.createQuery("SELECT d FROM LensMount d", LensMount.class).getResultList();
List<TripodHead> tripodHeads = em.createQuery("SELECT d FROM TripodHead d", TripodHead.class).getResultList();
List<AudioConnector> audioConnectors = em.createQuery("SELECT d FROM AudioConnector d", AudioConnector.class).getResultList();

return new DeviceTypeAttributeCollection(cameraResolutions, cameraSensors, cameraSystems, lensMounts, tripodHeads);
return new DeviceTypeAttributeCollection(cameraResolutions, cameraSystems, lensMounts, tripodHeads, audioConnectors);
}

//region utility functions
Expand Down
Loading

0 comments on commit be31695

Please sign in to comment.