Newer
Older
CosmosServer / src / main / java / com / example / cosmos_serversb / models / Groups.java
n-kande on 28 May 2019 2 KB jdkの変更
package com.example.cosmos_serversb.models;

import java.util.*;
import javax.inject.Singleton;
import com.example.cosmos_serversb.entities.*;

@Singleton
public class Groups {
    private static Groups thaInstance = null;
    private static ArrayList<Group> groups = new ArrayList<>();

    private Groups(){

    }

    public static Groups getInstance(){
        if(thaInstance == null){
            thaInstance = new Groups();
        }
        return thaInstance;
    }


    public static HashMap<String, String> getGroupsListByUid(String uId){
        return null;
    }

    public static Group createGroup(String name, String uId){
        //先にGidとuriの発行を行う
        Group testGroup = new Group("123456789", "http://test,com", name, uId);
        groups.add(testGroup);
        return testGroup;
    }

    public static Group getGroupByGid(String gId){
        Group editGroup;
        for (int i = 0; i < groups.size(); i++) {
            editGroup = groups.get(i);
            if (editGroup.getGid().equals(gId)) {
                return editGroup;
            }
        }
        return null;
    }

    public static DeleteResult deleteGroup(String gId){
        Group editGroup = Groups.getInstance().getGroupByGid(gId);
        if(editGroup == null){
            return DeleteResult.FAILURE;
        }
        //以下に削除処理を行う。
        return DeleteResult.SUCCESS;
    }

    public static HashMap<String, String> getMembersListByGid(String gId){
        return null;
    }

    public static HashMap<String, String> addMember(String gId, String uId){
        return null;
    }

    public static HashMap<String, String> deleteMember(String gId, String uId){
        return null;
    }

    public static HashMap<String, String> getRequestsListByGid(String gId){
        return null;
    }

    public static Request addRequests(String gId, String uId, String product,
                               String deadline, int location){
        //テスト用
        Request testRequest = new Request("123456789", "http://test,com", "1999/01/01/15:00:00",
                                            uId, product, "1999/01/01/15:00:00", 999);
        return testRequest;
    }

    public static Request getRequestDetailByGidAndRid(String gId, String rId){
        return null;
    }

    public static Request updateRequest(String gId, String rId, String uId, String product,
                                 String deadline, int location, boolean done){

        //テスト用
        Request testRequest = new Request("123456789", "http://test,com", "1999/01/01/15:00:00",
                                            uId, product, "1999/01/01/15:00:00", 999);

        return testRequest;
    }

    public static DeleteResult deleteRequest(String gId, String rId){
        return DeleteResult.SUCCESS;
    }
}