résolution conflit

Maxime
Maxime POINT 1 year ago
parent 0fa91cbf59
commit c4f977c45a

@ -10,4 +10,9 @@
</profile> </profile>
</annotationProcessing> </annotationProcessing>
</component> </component>
<component name="JavacSettings">
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
<module name="WebService" options="-parameters" />
</option>
</component>
</project> </project>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/WebService/src/main/java" charset="UTF-8" />
</component>
</project>

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="https://repo.maven.apache.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
</component>
</project>

@ -8,7 +8,7 @@
</list> </list>
</option> </option>
</component> </component>
<component name="ProjectRootManager"> <component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="liberica-17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" /> <output url="file://$PROJECT_DIR$/out" />
</component> </component>
</project> </project>

@ -1,34 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<<<<<<< HEAD
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>WebService</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>tp2</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
=======
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
@ -66,17 +38,6 @@
<artifactId>jakarta.persistence-api</artifactId> <artifactId>jakarta.persistence-api</artifactId>
</dependency> </dependency>
</dependencies> </dependencies>
>>>>>>> origin/feature/response
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>jakarta.persistence</groupId>
<artifactId>jakarta.persistence-api</artifactId>
</dependency>
</dependencies>
<build> <build>
<plugins> <plugins>

@ -1,16 +1,98 @@
package SAE.ApiREST.WebService.controller; package SAE.ApiREST.WebService.controller;
import SAE.ApiREST.WebService.model.Article;
import SAE.ApiREST.WebService.model.Collect;
import SAE.ApiREST.WebService.service.ICollectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.*;
import java.util.List;
@Controller @Controller
@RequestMapping("/CollectWebService") @RequestMapping("/CollectWebService")
public class CollectController { public class CollectController {
@Autowired
ICollectionService collectionService;
public CollectController() {
}
// region Collection
// region GET
@GetMapping(value = "/getAllCollection", produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody List<Collect> getAllCollection(){
return collectionService.getAllCollections();
}
@GetMapping(value = "/getCollectionById/{isbn}", produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody Collect getCollectionById(@PathVariable(value = "isbn") long isbn){
return collectionService.getCollectionById(isbn);
}
@GetMapping(value = "/getAllCollectionsByName/{name}", produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody List<Collect> getAllCollectionsByName(@PathVariable(value = "name") String name){
return collectionService.getAllCollectionsByName(name);
}
// endregion
// region DELETE
@DeleteMapping(value = "/deleteColletionById/{isbn}")
public @ResponseBody void deleteColletionById(@RequestParam("isbn") long isbn){
collectionService.deleteColletionById(isbn);
}
@DeleteMapping(value = "/deleteColletionByName/{name}")
public @ResponseBody void deleteColletionByName(@RequestParam("name") String name){
collectionService.deleteColletionByName(name);
}
@DeleteMapping(value = "/deleteAllColletionByName/{name}")
public @ResponseBody void deleteAllColletionByName(@RequestParam("name") String name){
collectionService.deleteAllColletionByName(name);
} }
// endregion
// region PUT
@PutMapping(value = "/addCollection")
public @ResponseBody void addCollection(@RequestParam("collection") Collect collection){
collectionService.addCollection(collection);
}
@PutMapping(value = "/addCollections")
public @ResponseBody void addCollections(@RequestParam("collections") List<Collect> collections){
collectionService.addCollections(collections);
}
// endregion
// region POST
@PostMapping(value="/modifyCollectionName", produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody void modifyCollectionName(@RequestParam("collection") Collect collection, @RequestParam("name") String name){
collectionService.modifyCollectionName(collection,name);
}
@PostMapping(value="/modifyCollectionNameById", produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody void modifyCollectionNameById(@RequestParam("isbn") long isbn, @RequestParam("name") String name){
collectionService.modifyCollectionNameById(isbn,name);
}
// endregion
// endregion
// region Article
@GetMapping(value = "/getAllArticles", produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody List<Article> getAllArticles(@RequestParam("collection") Collect collection){
return collectionService.getAllArticles(collection);
}
@PutMapping(value = "/addArticle", produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody void addArticle(@RequestParam("collection") Collect collection, @RequestParam("article") Article article){
collectionService.addArticle(collection,article);
}
@DeleteMapping(value = "/deleteArticle", produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody void deleteArticle(@RequestParam("collection") Collect collection, @RequestParam("article") Article article){
collectionService.deleteArticle(collection,article);
}
// endregion
}

@ -1,98 +0,0 @@
@org.springframework.stereotype.Controller
@Controller
@RequestMapping("/CollectionWebService")
public class CollectionController {
private ArrayList<Collection> collections = new ArrayList<>();
public Controller() {
}
// region Collection
// region GET
@GetMapping(value = "/getCollectionById/{isbn}", produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody Collection getCollectionById(@PathVariable(value = "isbn") long isbn){
for(Collection collection : this.collections){
if(collection.getId === isbn) {
return collection;
}
}
return null;
}
@GetMapping(value = "/getAllCollectionsByName/{name}", produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody List<Collection> getAllCollectionsByName(@PathVariable(value = "name") String name){
private ArrayList<Collection> repCollections = new ArrayList<Collection>();
for(Collection collection : this.collections){
if(collection.getName === name) {
repCollections.add(collection);
}
}
return repCollections;
}
// endregion
// region DELETE
@DeleteMapping(value = "/deleteColletionById/{isbn}")
public @ResponseBody void deleteColletionById(@RequestParam("isbn") long isbn){
Collection collection = getCollectionById(isbn);
this.collections.remove(collection);
}
@DeleteMapping(value = "/deleteColletionByName/{name}")
public @ResponseBody void deleteColletionByName(@RequestParam("name") String name){
ArrayList<Collection> collectionsByName = getAllCollectionsByName(name);
this.collections.remove(collectionsByName[0]);
}
@DeleteMapping(value = "/deleteAllColletionByName/{name}")
public @ResponseBody void deleteAllColletionByName(@RequestParam("name") String name){
ArrayList<Collection> collectionsByName = getAllCollectionsByName(name);
this.collections.removeAll(collectionsByName);
}
// endregion
// region PUT
@PutMapping(value = "/addCollection")
public @ResponseBody void addCollection(@RequestParam("collection") Collection collection){
this.collections.add(collection);
}
@PutMapping(value = "/addCollections")
public @ResponseBody void addCollections(@RequestParam("collections") List<Collection> collections){
this.collections.addAll(collections);
}
// endregion
// region POST
@PostMapping("/modifyCollectionName", produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody void modifyCollectionName(@RequestParam("collection") Collection collection, @RequestParam("name") String name){
collection.setName(name);
}
@PostMapping("/modifyCollectionNameById", produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody void modifyCollectionNameById(@RequestParam("isbn") long isbn, @RequestParam("name") String name){
Collection collection = getCollectionById(isbn);
modifyCollectionName(collection,name);
}
// endregion
// endregion
// region Article
@GetMapping(value = "/getAllArticles", produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody List<Article> getAllArticles(@RequestParam("collection") Collection collection){
return collection.getAllArticles;
}
@PutMapping(value = "/addArticle", produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody void addArticle(@RequestParam("collection") Collection collection, @RequestParam("article") Article article){
collection.addArticle
}
@DeleteMapping(value = "/deleteArticle", produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody void deleteArticle(@RequestParam("collection") Collection collection, @RequestParam("article") Article article){
collection.deleteArticle(article);
}
// endregion
}

@ -12,11 +12,7 @@ import jakarta.persistence.Id;
public class Article { public class Article {
@Id @Id
@GeneratedValue(strategy = GenerationType.AUTO) @GeneratedValue(strategy = GenerationType.AUTO)
<<<<<<< HEAD
=======
String id; String id;
>>>>>>> origin/feature/response
String title; String title;
String URL; String URL;
LocalDate dateAdded; LocalDate dateAdded;

@ -1,25 +1,44 @@
package SAE.ApiREST.WebService.service; package SAE.ApiREST.WebService.service;
import SAE.ApiREST.WebService.model.Collect; import SAE.ApiREST.WebService.model.Collect;
import SAE.ApiREST.WebService.model.Teacher;
import java.time.LocalDate;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
import SAE.ApiREST.WebService.model.Article; import SAE.ApiREST.WebService.model.Article;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import SAE.ApiREST.WebService.model.Collection; import SAE.ApiREST.WebService.model.Collect;
@Service @Service
public class StubCollectionService implements ICollectionService { public class StubCollectionService implements ICollectionService {
private ArrayList<Collect> collections;
@Override
public List<Collect> getAllCollections() { public List<Collect> getAllCollections() {
return this.collections; List<Collect> collections = new ArrayList<>();
collections.add(new Collect("collect1", new Teacher(1, "12-01-2023", "aline.alipres@gmail.com", "MsGarconManque")));
Collect collection2 = new Collect("collect2", new Teacher(1, "12-01-2023", "aline.alipres@gmail.com", "MsGarconManque"));
collection2.addArticle(new Article("toi","azezeaea", LocalDate.now().minusMonths(1),LocalDate.now().minusMonths(2),true,1));
collections.add(collection2);
Collect collection3 = new Collect("collect3", new Teacher(1, "12-01-2023", "aline.alipres@gmail.com", "MsGarconManque"));
collection3.addArticle(new Article("toi","azezeaea",LocalDate.now().minusMonths(1),LocalDate.now().minusMonths(2),true,1));
collection3.addArticle(new Article("toi","azezeaea",LocalDate.now().minusMonths(1),LocalDate.now().minusMonths(2),true,1));
collections.add(collection3);
return collections;
} }
// region Collection // region Collection
// region GET // region GET
@Override
public Collect getCollectionById(long isbn){ public Collect getCollectionById(long isbn){
for(Collect collection : this.collections){ List<Collect> collections = getAllCollections();
for(Collect collection : collections){
if(collection.getId() == isbn) { if(collection.getId() == isbn) {
return collection; return collection;
} }
@ -28,14 +47,11 @@ public class StubCollectionService implements ICollectionService {
} }
@Override @Override
public List<Collection> getAllCollectionsByName(String name){
private ArrayList<Collection> repCollections = new ArrayList<Collection>();
for(Collection collection : this.collections){
if(collection.getName() == name) {
public List<Collect> getAllCollectionsByName(String name){ public List<Collect> getAllCollectionsByName(String name){
List<Collect> collections = getAllCollections();
ArrayList<Collect> repCollections = new ArrayList<Collect>(); ArrayList<Collect> repCollections = new ArrayList<Collect>();
for(Collect collection : this.collections){ for(Collect collection : collections){
if(collection.getName() == name) { if(Objects.equals(collection.getName(), name)) {
repCollections.add(collection); repCollections.add(collection);
} }
} }
@ -46,35 +62,42 @@ public class StubCollectionService implements ICollectionService {
// region DELETE // region DELETE
@Override @Override
public void deleteColletionById(long isbn){ public void deleteColletionById(long isbn){
List<Collect> collections = getAllCollections();
Collect collection = getCollectionById(isbn); Collect collection = getCollectionById(isbn);
this.collections.remove(collection); collections.remove(collection);
} }
@Override @Override
public void deleteColletionByName(String name){ public void deleteColletionByName(String name){
List<Collect> collections = getAllCollections();
List<Collect> collectionsByName = getAllCollectionsByName(name); List<Collect> collectionsByName = getAllCollectionsByName(name);
this.collections.remove(collectionsByName.get(0)); collections.remove(collectionsByName.get(0));
} }
@Override @Override
public void deleteAllColletionByName(String name){ public void deleteAllColletionByName(String name){
List<Collect> collections = getAllCollections();
List<Collect> collectionsByName = getAllCollectionsByName(name); List<Collect> collectionsByName = getAllCollectionsByName(name);
this.collections.removeAll(collectionsByName); collections.removeAll(collectionsByName);
} }
@Override @Override
public void addCollection(Collect collection) { public void addCollection(Collect collection) {
this.collections.add(collection); List<Collect> collections = getAllCollections();
collections.add(collection);
} }
// endregion // endregion
// region PUT // region PUT
@Override
public void addCollections(List<Collect> collections){ public void addCollections(List<Collect> collections){
this.collections.addAll(collections); List<Collect> collectionsStub = getAllCollections();
collections.addAll(collectionsStub);
} }
// endregion // endregion
// region POST // region POST
@Override
public void modifyCollectionName(Collect collection, String name){ public void modifyCollectionName(Collect collection, String name){
collection.setName(name); collection.setName(name);
} }
@ -88,12 +111,15 @@ public class StubCollectionService implements ICollectionService {
// endregion // endregion
// region Article // region Article
@Override
public List<Article> getAllArticles(Collect collect){ public List<Article> getAllArticles(Collect collect){
return collect.getAllArticles(); return collect.getAllArticles();
} }
@Override
public void addArticle(Collect collect, Article article){ public void addArticle(Collect collect, Article article){
collect.addArticle(article); collect.addArticle(article);
} }
@Override
public void deleteArticle(Collect collect, Article article){ public void deleteArticle(Collect collect, Article article){
collect.removeArticle(article); collect.removeArticle(article);
} }

Loading…
Cancel
Save