Skip to content

Commit 8136def

Browse files
author
Zahrun
committed
Backup database + andoid: requete générique
1 parent 32c20eb commit 8136def

File tree

9 files changed

+356
-17
lines changed

9 files changed

+356
-17
lines changed

Android/app/app.iml

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@
9090
<orderEntry type="library" exported="" name="recyclerview-v7-23.1.1" level="project" />
9191
<orderEntry type="library" exported="" name="support-v4-23.1.1" level="project" />
9292
<orderEntry type="library" exported="" name="jackson-annotations-2.3.0" level="project" />
93-
<orderEntry type="library" exported="" name="jackson-core-2.3.2" level="project" />
9493
<orderEntry type="library" exported="" name="support-annotations-23.1.1" level="project" />
94+
<orderEntry type="library" exported="" name="jackson-core-2.3.2" level="project" />
9595
<orderEntry type="library" exported="" name="appcompat-v7-23.1.1" level="project" />
9696
<orderEntry type="library" exported="" name="spring-android-core-2.0.0.M3" level="project" />
9797
<orderEntry type="library" exported="" name="design-23.1.1" level="project" />

Android/app/src/main/java/gei/soprapp/FragmentSearch.java

+1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ public void onClick(View v) {
8383
fab.setOnClickListener(new View.OnClickListener() {
8484
@Override
8585
public void onClick(final View v) {
86+
FragmentSearchResults.setRequest(null,null,null,0,0,null);
8687
((MainActivity) getContext()).getmSectionsPagerAdapter().switchSearchFragment();
8788
}
8889
});

Android/app/src/main/java/gei/soprapp/FragmentSearchResults.java

+3-9
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,14 @@ public void onViewCreated(final View view, Bundle savedInstanceState) {
4848
new Thread(new Runnable() {
4949
@Override
5050
public void run() {
51-
String uri = "http://176.31.1.146:8080/webapp/rest/entities.sites";
52-
// Create a new RestTemplate instance
53-
RestTemplate restTemplate = new RestTemplate();
54-
restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
55-
ResponseEntity<Sites[]> responseEntity = restTemplate.getForEntity(uri, Sites[].class);
56-
57-
final Sites[] result = responseEntity.getBody();
51+
final Sites[] sites = Requetes.getSites();
5852
final TextView textView = (TextView) view.findViewById(R.id.resultatText);
5953
textView.post(new Runnable() {
6054
@Override
6155
public void run() {
6256
String text = new String();
63-
for (Sites site : result){
64-
text+=site.toString()+"\n";
57+
for (Sites site : sites) {
58+
text += site.toString() + "\n";
6559
}
6660
textView.setText("Petit test de requete (sites):\n" + text);
6761
}

Android/app/src/main/java/gei/soprapp/Globals.java

+3
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,7 @@ public class Globals {
88
public final static String listeSitesKey = "PREF_SITES";
99
public final static String sallesPreferenceKey = "pref_key_salles";
1010
public final static String sitesPreferenceKey = "pref_key_site";
11+
12+
public final static String BASE_URI="http://176.31.1.146:8080/webapp";
13+
public final static String REST_URI=BASE_URI+"/rest/";
1114
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package gei.soprapp;
2+
3+
import android.widget.TextView;
4+
5+
import org.springframework.http.ResponseEntity;
6+
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
7+
import org.springframework.web.client.RestTemplate;
8+
9+
import gei.soprapp.entities.Sites;
10+
11+
/**
12+
* Created by Clément Baudouin on 11/01/2016.
13+
*/
14+
public class Requetes {
15+
16+
private static <T> T requete(String URI, Class<T> type) {
17+
// Create a new RestTemplate instance
18+
RestTemplate restTemplate = new RestTemplate();
19+
restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
20+
ResponseEntity<T>responseEntity = restTemplate.getForEntity(URI, type);
21+
return responseEntity.getBody();
22+
}
23+
24+
public static Sites[] getSites(){
25+
String uri = Globals.REST_URI+"entities.sites";
26+
return requete(uri, Sites[].class);
27+
}
28+
}

SopraBD-2016-01-11.sql

+307
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,307 @@
1+
-- phpMyAdmin SQL Dump
2+
-- version 3.4.11.1deb2+deb7u2
3+
-- http://www.phpmyadmin.net
4+
--
5+
-- Client: localhost
6+
-- Généré le: Lun 11 Janvier 2016 à 00:59
7+
-- Version du serveur: 5.5.46
8+
-- Version de PHP: 5.4.4-14+deb7u5
9+
10+
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
11+
SET time_zone = "+00:00";
12+
13+
14+
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
15+
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
16+
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
17+
/*!40101 SET NAMES utf8 */;
18+
19+
--
20+
-- Base de données: `SopraBD`
21+
--
22+
23+
-- --------------------------------------------------------
24+
25+
--
26+
-- Structure de la table `Equipments`
27+
--
28+
29+
CREATE TABLE IF NOT EXISTS `Equipments` (
30+
`equipmentID` int(3) unsigned NOT NULL AUTO_INCREMENT,
31+
`description` text COLLATE utf8_unicode_ci,
32+
PRIMARY KEY (`equipmentID`)
33+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=5 ;
34+
35+
--
36+
-- Contenu de la table `Equipments`
37+
--
38+
39+
INSERT INTO `Equipments` (`equipmentID`, `description`) VALUES
40+
(1, 'Visio'),
41+
(2, 'Téléphone'),
42+
(3, 'Salle Digilab'),
43+
(4, 'Sécurisée');
44+
45+
-- --------------------------------------------------------
46+
47+
--
48+
-- Structure de la table `InvitedUsers`
49+
--
50+
51+
CREATE TABLE IF NOT EXISTS `InvitedUsers` (
52+
`invitedUserID` int(10) unsigned NOT NULL AUTO_INCREMENT,
53+
`reservationRef` int(10) unsigned NOT NULL,
54+
`userRef` int(10) unsigned NOT NULL,
55+
PRIMARY KEY (`invitedUserID`),
56+
KEY `userRef` (`userRef`),
57+
KEY `reservationRef` (`reservationRef`)
58+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;
59+
60+
-- --------------------------------------------------------
61+
62+
--
63+
-- Structure de la table `OldInvitedUsers`
64+
--
65+
66+
CREATE TABLE IF NOT EXISTS `OldInvitedUsers` (
67+
`oldInvitedUserID` int(10) unsigned NOT NULL AUTO_INCREMENT,
68+
`oldReservationRef` int(12) unsigned NOT NULL,
69+
`userRef` int(10) unsigned NOT NULL,
70+
PRIMARY KEY (`oldInvitedUserID`),
71+
KEY `oldReservationRef` (`oldReservationRef`),
72+
KEY `oldInvitedUserID` (`userRef`)
73+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;
74+
75+
-- --------------------------------------------------------
76+
77+
--
78+
-- Structure de la table `OldReservations`
79+
--
80+
81+
CREATE TABLE IF NOT EXISTS `OldReservations` (
82+
`oldReservationID` int(12) unsigned NOT NULL AUTO_INCREMENT,
83+
`roomRef` int(10) unsigned NOT NULL,
84+
`start` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
85+
`end` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
86+
`ownerRef` int(10) unsigned NOT NULL,
87+
PRIMARY KEY (`oldReservationID`),
88+
KEY `roomRef` (`roomRef`),
89+
KEY `ownerRef` (`ownerRef`)
90+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=5 ;
91+
92+
--
93+
-- Contenu de la table `OldReservations`
94+
--
95+
96+
INSERT INTO `OldReservations` (`oldReservationID`, `roomRef`, `start`, `end`, `ownerRef`) VALUES
97+
(1, 2, '2016-01-14 14:30:00', '2016-01-14 15:00:00', 15),
98+
(2, 1, '2015-12-07 11:18:54', '2015-12-11 10:20:54', 1),
99+
(3, 3, '2015-12-22 09:00:00', '2015-12-22 13:00:00', 1);
100+
101+
-- --------------------------------------------------------
102+
103+
--
104+
-- Structure de la table `Reservations`
105+
--
106+
107+
CREATE TABLE IF NOT EXISTS `Reservations` (
108+
`reservationID` int(10) unsigned NOT NULL AUTO_INCREMENT,
109+
`roomRef` int(5) unsigned NOT NULL,
110+
`start` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
111+
`end` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
112+
`ownerRef` int(10) unsigned NOT NULL,
113+
PRIMARY KEY (`reservationID`),
114+
KEY `roomRef` (`roomRef`),
115+
KEY `ownerRef` (`ownerRef`)
116+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=4 ;
117+
118+
--
119+
-- Contenu de la table `Reservations`
120+
--
121+
122+
INSERT INTO `Reservations` (`reservationID`, `roomRef`, `start`, `end`, `ownerRef`) VALUES
123+
(3, 1, '2016-01-10 22:13:49', '2016-01-22 17:10:00', 6);
124+
125+
-- --------------------------------------------------------
126+
127+
--
128+
-- Structure de la table `RoomEquipments`
129+
--
130+
131+
CREATE TABLE IF NOT EXISTS `RoomEquipments` (
132+
`roomEquipmentID` int(10) unsigned NOT NULL AUTO_INCREMENT,
133+
`roomRef` int(5) unsigned NOT NULL,
134+
`equipmentRef` int(3) unsigned NOT NULL,
135+
PRIMARY KEY (`roomEquipmentID`),
136+
KEY `roomRef` (`roomRef`),
137+
KEY `equipmentRef` (`equipmentRef`)
138+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=7 ;
139+
140+
--
141+
-- Contenu de la table `RoomEquipments`
142+
--
143+
144+
INSERT INTO `RoomEquipments` (`roomEquipmentID`, `roomRef`, `equipmentRef`) VALUES
145+
(1, 1, 1),
146+
(2, 1, 2),
147+
(3, 2, 4),
148+
(4, 3, 3),
149+
(5, 3, 1),
150+
(6, 3, 2);
151+
152+
-- --------------------------------------------------------
153+
154+
--
155+
-- Structure de la table `Rooms`
156+
--
157+
158+
CREATE TABLE IF NOT EXISTS `Rooms` (
159+
`roomID` int(5) unsigned NOT NULL AUTO_INCREMENT,
160+
`siteRef` int(4) unsigned NOT NULL,
161+
`number` text COLLATE utf8_unicode_ci NOT NULL,
162+
`capacity` smallint(4) NOT NULL,
163+
PRIMARY KEY (`roomID`),
164+
KEY `siteRef` (`siteRef`)
165+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=4 ;
166+
167+
--
168+
-- Contenu de la table `Rooms`
169+
--
170+
171+
INSERT INTO `Rooms` (`roomID`, `siteRef`, `number`, `capacity`) VALUES
172+
(1, 1, 'Salle Fourier', 60),
173+
(2, 1, 'Salle 102', 30),
174+
(3, 2, 'Salle 3', 3);
175+
176+
-- --------------------------------------------------------
177+
178+
--
179+
-- Structure de la table `Sites`
180+
--
181+
182+
CREATE TABLE IF NOT EXISTS `Sites` (
183+
`siteID` int(4) unsigned NOT NULL AUTO_INCREMENT,
184+
`name` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
185+
`address` text COLLATE utf8_unicode_ci NOT NULL,
186+
`description` text COLLATE utf8_unicode_ci,
187+
PRIMARY KEY (`siteID`)
188+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=3 ;
189+
190+
--
191+
-- Contenu de la table `Sites`
192+
--
193+
194+
INSERT INTO `Sites` (`siteID`, `name`, `address`, `description`) VALUES
195+
(1, 'INSA Toulouse', 'Avenue de Rangueil', 'Le meilleur endroit du monde'),
196+
(2, 'GEI', 'Impasse de l''informatique', NULL);
197+
198+
-- --------------------------------------------------------
199+
200+
--
201+
-- Structure de la table `test`
202+
--
203+
204+
CREATE TABLE IF NOT EXISTS `test` (
205+
`name` varchar(8) NOT NULL,
206+
`age` int(8) NOT NULL
207+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
208+
209+
--
210+
-- Contenu de la table `test`
211+
--
212+
213+
INSERT INTO `test` (`name`, `age`) VALUES
214+
('jr', 0),
215+
('jack', 21),
216+
('name', 25);
217+
218+
-- --------------------------------------------------------
219+
220+
--
221+
-- Structure de la table `Users`
222+
--
223+
224+
CREATE TABLE IF NOT EXISTS `Users` (
225+
`userID` int(10) unsigned NOT NULL AUTO_INCREMENT,
226+
`name` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
227+
`surname` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
228+
`mailAddress` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
229+
`password` text COLLATE utf8_unicode_ci NOT NULL,
230+
`admin` tinyint(1) NOT NULL DEFAULT '0',
231+
PRIMARY KEY (`userID`)
232+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=21 ;
233+
234+
--
235+
-- Contenu de la table `Users`
236+
--
237+
238+
INSERT INTO `Users` (`userID`, `name`, `surname`, `mailAddress`, `password`, `admin`) VALUES
239+
(1, 'Le Botlan', 'Didier', '[email protected]', 'pizza', 1),
240+
(3, 'testUser', 'test', '[email protected]', 'a', 1),
241+
(5, 'Donald', 'Dodo', '[email protected]', 'coincoin', 0),
242+
(6, 'Marre', 'Daniel', '[email protected]', 'marre', 0),
243+
(7, 'lala', 'lili', '[email protected]', 'lala', 0),
244+
(14, 'rgautier', 'rgautier', '[email protected]', 'rgautier', 1),
245+
(15, 'Machin', 'Truc', '[email protected]', 'mc', 0),
246+
(17, 'root', 'admin', '[email protected]', 'adminadmin', 1),
247+
(20, 'Bertin', 'Alexis', '[email protected]', 'alexis', 1);
248+
249+
--
250+
-- Contraintes pour les tables exportées
251+
--
252+
253+
--
254+
-- Contraintes pour la table `InvitedUsers`
255+
--
256+
ALTER TABLE `InvitedUsers`
257+
ADD CONSTRAINT `InvitedUsers_ibfk_1` FOREIGN KEY (`reservationRef`) REFERENCES `Reservations` (`reservationID`),
258+
ADD CONSTRAINT `InvitedUsers_ibfk_2` FOREIGN KEY (`userRef`) REFERENCES `Users` (`userID`);
259+
260+
--
261+
-- Contraintes pour la table `OldInvitedUsers`
262+
--
263+
ALTER TABLE `OldInvitedUsers`
264+
ADD CONSTRAINT `OldInvitedUsers_ibfk_1` FOREIGN KEY (`oldReservationRef`) REFERENCES `OldReservations` (`oldReservationID`),
265+
ADD CONSTRAINT `OldInvitedUsers_ibfk_2` FOREIGN KEY (`userRef`) REFERENCES `Users` (`userID`);
266+
267+
--
268+
-- Contraintes pour la table `OldReservations`
269+
--
270+
ALTER TABLE `OldReservations`
271+
ADD CONSTRAINT `OldReservations_ibfk_1` FOREIGN KEY (`roomRef`) REFERENCES `Rooms` (`roomID`),
272+
ADD CONSTRAINT `OldReservations_ibfk_2` FOREIGN KEY (`ownerRef`) REFERENCES `Users` (`userID`);
273+
274+
--
275+
-- Contraintes pour la table `Reservations`
276+
--
277+
ALTER TABLE `Reservations`
278+
ADD CONSTRAINT `Reservations_ibfk_1` FOREIGN KEY (`roomRef`) REFERENCES `Rooms` (`roomID`),
279+
ADD CONSTRAINT `Reservations_ibfk_2` FOREIGN KEY (`ownerRef`) REFERENCES `Users` (`userID`);
280+
281+
--
282+
-- Contraintes pour la table `RoomEquipments`
283+
--
284+
ALTER TABLE `RoomEquipments`
285+
ADD CONSTRAINT `RoomEquipments_ibfk_1` FOREIGN KEY (`roomRef`) REFERENCES `Rooms` (`roomID`),
286+
ADD CONSTRAINT `RoomEquipments_ibfk_2` FOREIGN KEY (`equipmentRef`) REFERENCES `Equipments` (`equipmentID`);
287+
288+
--
289+
-- Contraintes pour la table `Rooms`
290+
--
291+
ALTER TABLE `Rooms`
292+
ADD CONSTRAINT `Rooms_ibfk_1` FOREIGN KEY (`siteRef`) REFERENCES `Sites` (`siteID`);
293+
294+
DELIMITER $$
295+
--
296+
-- Événements
297+
--
298+
CREATE DEFINER=`root`@`localhost` EVENT `deleteOldReservation` ON SCHEDULE EVERY 1 DAY STARTS '2016-01-10 22:37:23' ON COMPLETION NOT PRESERVE ENABLE DO INSERT INTO `OldReservations`(`oldReservationID`, `roomRef`, `start`, `end`, `ownerRef`)
299+
SELECT null, `roomRef`, `start`, `end`, `ownerRef`
300+
FROM `Reservations`
301+
WHERE end < NOW()$$
302+
303+
DELIMITER ;
304+
305+
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
306+
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
307+
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

0 commit comments

Comments
 (0)