-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
90 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
AndroidProject/app/src/main/java/es/unican/gasolineras/model/PuntoInteres.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package es.unican.gasolineras.model; | ||
|
||
import androidx.room.ColumnInfo; | ||
import androidx.room.Entity; | ||
import androidx.room.Index; | ||
import androidx.room.PrimaryKey; | ||
|
||
@Entity(indices = {@Index(value = {"nombre"}, unique = true)}) | ||
public class PuntoInteres { | ||
@PrimaryKey | ||
public int idPuntoInteres; | ||
|
||
@ColumnInfo(name = "nombre") | ||
public String nombre; | ||
|
||
@ColumnInfo(name = "latitud") | ||
public double latitud; | ||
|
||
@ColumnInfo(name = "longitud") | ||
public double longitud; | ||
} |
11 changes: 11 additions & 0 deletions
11
AndroidProject/app/src/main/java/es/unican/gasolineras/repository/AppDatabase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package es.unican.gasolineras.repository; | ||
|
||
import androidx.room.Database; | ||
import androidx.room.RoomDatabase; | ||
|
||
import es.unican.gasolineras.model.PuntoInteres; | ||
|
||
@Database(entities = {PuntoInteres.class}, version = 1) | ||
public abstract class AppDatabase extends RoomDatabase { | ||
public abstract PuntosInteresDao puntosInteresDao(); | ||
} |
34 changes: 34 additions & 0 deletions
34
AndroidProject/app/src/main/java/es/unican/gasolineras/repository/PuntosInteresDao.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package es.unican.gasolineras.repository; | ||
|
||
import androidx.room.Dao; | ||
import androidx.room.Delete; | ||
import androidx.room.Insert; | ||
import androidx.room.Query; | ||
|
||
import java.util.List; | ||
|
||
import es.unican.gasolineras.model.PuntoInteres; | ||
|
||
@Dao | ||
public interface PuntosInteresDao { | ||
@Query("SELECT * FROM Puntointeres") | ||
List<PuntoInteres> getAll(); | ||
|
||
// Buscar por id | ||
@Query("SELECT * FROM PuntoInteres WHERE idPuntoInteres IN (:PuntoInteresId)") | ||
PuntoInteres loadById(int PuntoInteresId); | ||
|
||
// Buscar por nombre | ||
@Query("SELECT * FROM PuntoInteres WHERE nombre IN (:NombrePuntoInteres)") | ||
PuntoInteres loadByName(String NombrePuntoInteres); | ||
|
||
// Buscar por latitud y longitud exactas | ||
@Query("SELECT * FROM PuntoInteres WHERE latitud = :lat AND longitud = :lon") | ||
PuntoInteres loadByLatLon(double lat, double lon); | ||
|
||
@Insert | ||
void insertAll(PuntoInteres... puntoInteres); | ||
|
||
@Delete | ||
void delete(PuntoInteres puntoInteres); | ||
} |