|
|
|
@ -18,13 +18,13 @@ public class StubCollectionService implements ICollectionService {
|
|
|
|
|
public List<Collect> getAllCollections() {
|
|
|
|
|
List<Collect> collections = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
collections.add(new Collect("collect1", new Teacher(1, "12-01-2023", "aline.alipres@gmail.com", "MsGarconManque")));
|
|
|
|
|
collections.add(new Collect("collect1", new Teacher(1, "12-03-2023", "aline.alipres@gmail.com", "MsGarconManque"),0));
|
|
|
|
|
|
|
|
|
|
Collect collection2 = new Collect("collect2", new Teacher(1, "12-01-2023", "aline.alipres@gmail.com", "MsGarconManque"));
|
|
|
|
|
Collect collection2 = new Collect("collect2", new Teacher(1, "12-03-2023", "aline.alipres@gmail.com", "MsGarconManque"),1);
|
|
|
|
|
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"));
|
|
|
|
|
Collect collection3 = new Collect("collect3", new Teacher(1, "12-03-2023", "aline.alipres@gmail.com", "MsGarconManque"),3);
|
|
|
|
|
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);
|
|
|
|
@ -36,15 +36,14 @@ public class StubCollectionService implements ICollectionService {
|
|
|
|
|
|
|
|
|
|
// region GET
|
|
|
|
|
@Override
|
|
|
|
|
public Collect getCollectionById(long isbn){
|
|
|
|
|
public Collect getCollectionById(Integer id){
|
|
|
|
|
List<Collect> collections = getAllCollections();
|
|
|
|
|
for(Collect collection : collections){
|
|
|
|
|
if(collection.getId() == isbn) {
|
|
|
|
|
return collection;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
return collections.get(id);
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<Collect> getAllCollectionsByName(String name){
|
|
|
|
@ -61,9 +60,9 @@ public class StubCollectionService implements ICollectionService {
|
|
|
|
|
|
|
|
|
|
// region DELETE
|
|
|
|
|
@Override
|
|
|
|
|
public void deleteColletionById(long isbn){
|
|
|
|
|
public void deleteColletionById(Integer id){
|
|
|
|
|
List<Collect> collections = getAllCollections();
|
|
|
|
|
Collect collection = getCollectionById(isbn);
|
|
|
|
|
Collect collection = getCollectionById(id);
|
|
|
|
|
collections.remove(collection);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -103,8 +102,8 @@ public class StubCollectionService implements ICollectionService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void modifyCollectionNameById(long isbn, String name){
|
|
|
|
|
Collect collection = getCollectionById(isbn);
|
|
|
|
|
public void modifyCollectionNameById(Integer id, String name){
|
|
|
|
|
Collect collection = getCollectionById(id);
|
|
|
|
|
modifyCollectionName(collection,name);
|
|
|
|
|
}
|
|
|
|
|
// endregion
|
|
|
|
@ -112,8 +111,13 @@ public class StubCollectionService implements ICollectionService {
|
|
|
|
|
|
|
|
|
|
// region Article
|
|
|
|
|
@Override
|
|
|
|
|
public List<Article> getAllArticles(Collect collect){
|
|
|
|
|
return collect.getAllArticles();
|
|
|
|
|
public List<Article> getAllArticlesById(Integer id){
|
|
|
|
|
List<Article> result = new ArrayList<>();
|
|
|
|
|
Collect collect = getCollectionById(id);
|
|
|
|
|
if (result.addAll(collect.getAllArticles())){
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public void addArticle(Collect collect, Article article){
|
|
|
|
|