Skip to content
Snippets Groups Projects
Commit 13d4d73c authored by Jordan Woolley's avatar Jordan Woolley
Browse files

Changes to groups and language

parent eb3c48f3
Branches
No related tags found
No related merge requests found
Showing
with 190 additions and 82 deletions
...@@ -17,6 +17,13 @@ CREATE TABLE calendar ( ...@@ -17,6 +17,13 @@ CREATE TABLE calendar (
end_date DATE NOT NULL) end_date DATE NOT NULL)
WITH (OIDS = FALSE); WITH (OIDS = FALSE);
CREATE TABLE grp (
id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
groupId BIGINT NOT NULL REFERENCES grp ON DELETE RESTRICT,
groupName TEXT NOT NULL,
groupType TEXT NOT NULL)
WITH (OIDS = FALSE);
CREATE TABLE route ( CREATE TABLE route (
id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
agency_id BIGINT NOT NULL REFERENCES agency ON DELETE RESTRICT, agency_id BIGINT NOT NULL REFERENCES agency ON DELETE RESTRICT,
... ...
......
/* /*package edu.drexel.TrainDemo.controllers;
package edu.drexel.TrainDemo.controllers.users;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import edu.drexel.TrainDemo.models.Group;
import edu.drexel.TrainDemo.models.GroupType;
import edu.drexel.TrainDemo.repositories.GroupRepository;
import edu.drexel.TrainDemo.Services.GroupService;
@Controller
public class GroupController public class GroupController
{ {
private GroupService groupService;
public GroupController(GroupRepository groupRepository)
{
this.groupService = groupService;
}
@RequestMapping("/group")
String search(Model model){
List<Group> groups = groupRepository.findAll();
model.addAttribute("groups", groups);
System.out.println("groups");
return "groups";
}
} // End of GroupController } // End of GroupController
*/ */
/* package edu.drexel.TrainDemo.models;
package edu.drexel.TrainDemo.models.users;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import edu.drexel.TrainDemo.models.GroupType;
@Entity
public class Group public class Group
{ {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private String groupName; private String groupName;
private Integer groupId; private Integer groupId;
private GroupType groupType; private GroupType groupType;
private Set<Permissions> permission = new HashSet<>();
public Group(String groupName) protected Group()
{ {
this.groupName = groupName;
}
public String getGroupName()
{
return groupName;
} }
public void setGroupName(String groupName) public Group(String groupName, GroupType groupType, Integer groupId)
{ {
this.groupName = groupName; this.groupName = groupName;
this.groupType = groupType;
this.groupId = groupId;
} }
public GroupType getGroupType() public String getGroupName()
{ {
return groupType; return groupName;
} }
public void setGroupType(GroupType groupType) public GroupType getGroupType()
{ {
this.groupType = groupType; return groupType;
} }
public Integer getGroupId() public Integer getGroupId()
...@@ -43,21 +47,13 @@ public class Group ...@@ -43,21 +47,13 @@ public class Group
return groupId; return groupId;
} }
public void setGroupId(Integer groupId) @Override
{ public String toString() {
this.groupId = groupId; return "Group{" +
} "id=" + groupId +
", name='" + groupName +
public Set<Permissions> getPermissions() ", type='" + groupType +'\'' +
{ '}';
return permission;
}
public void setPermissions(Set<Permissions> permission)
{
this.permission = permission;
} }
} // End of Group. } // End of Group.
*/
/* package edu.drexel.TrainDemo.models;
package edu.drexel.TrainDemo.models.users;
public enum GroupType public enum GroupType
{ {
...@@ -8,5 +6,3 @@ public enum GroupType ...@@ -8,5 +6,3 @@ public enum GroupType
Employee, Customer Employee, Customer
} // End of GroupType. } // End of GroupType.
*/
/*
// Package.
// Import Files.
public interface LanguageRepository extends CrudRepository <Language, String>
{
Language findByCode(String code);
} // End of LanguageRepository.
*/
/* package edu.drexel.TrainDemo.repositories;
package edu.drexel.TrainDemo.repositories.users;
import edu.drexel.TrainDemo.models.Group; import edu.drexel.TrainDemo.models.Group;
import edu.drexel.TrainDemo.models.GroupType; import edu.drexel.TrainDemo.models.GroupType;
import edu.drexel.TrainDemo.models.Permissions;
import org.springframework.data.repository.CrudRepository; import org.springframework.data.repository.CrudRepository;
import java.util.ArrayList; import java.util.List;
import java.util.Set;
public interface GroupRepository extends CrudRepository<Group, String> public interface GroupRepository extends CrudRepository<Group, String>
{ {
Group findById(Integer groupId); List<Group> findAll();
ArrayList<Group> findAll(); // List<Group> findByIds(Integer groupId);
ArrayList<Group> findByPermissions(Permissions permission); // List<Group> findByNames(String groupName);
ArrayList<Group> findByIds(Set<Integer> groupId); // List<Group> findByType(GroupType groupType);
ArrayList<Group> findByNames(ArrayList<String> groupName);
ArrayList<Group> findByType(GroupType groupType);
Group findByGroupName(String name); Group findByGroupName(String name);
} } // End of Group Repository
*/
/*
// Package.
// Import file.
import java.util.ArrayList;
public interface LanguageFacade
{
ArrayList<Language> getLanguages();
} // End of LanguageFacade.
*/
/*
// Package.
// Import Files.
import java.util.List;
public class LanguageFacadeImpl implements LanguageFacade {
private LanguageService languageService;
public List<Language> getLanguages()
{
ArrayList<Language> languages = languageService.getLanguages();
return languages;
}
} // End of LanguageFacadeImpl.
*/
/*
// Package.
// Import Files.
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
public class LanguageServiceImpl
{
private static final Logger LOGGER = LoggerFactory.getLogger(LanguageServiceImpl.class);
private LanguageRepository languageRepository;
public LanguageServiceImpl(LanguageRepository languageRepository)
{
super(languageRepository);
this.languageRepository = languageRepository;
}
public Language getByCode(String code) throws ServiceException {
return languageRepository.findByCode(code);
}
System.out.println();
} // End of LanguageServiceImpl.
*/
/* package edu.drexel.TrainDemo.services;
package edu.drexel.TrainDemo.services.users; import java.util.List;
import java.util.ArrayList;
import java.util.Set; import java.util.Set;
import edu.drexel.TrainDemo.models.Group; import edu.drexel.TrainDemo.models.Group;
import edu.drexel.TrainDemo.models.GroupType; import edu.drexel.TrainDemo.models.GroupType;
public interface GroupService public interface GroupService
{ {
ArrayList<Group> listGroup(GroupType groupType); public List<Group> getGroups();
ArrayList<Group> listGroupByIds(Set<Integer> groupId); // List<Group> listGroup(GroupType groupType);
ArrayList<Group> listGroupByNames(ArrayList<String> names); // List<Group> listGroupByNames(List<String> names);
Group findByName(String groupName); Group findByName(String groupName);
} // End of GroupServices. // Group createGroup(Integer groupId, String groupName, GroupType groupType);
*/ } // End of GroupServices.
/* package edu.drexel.TrainDemo.services;
package edu.drexel.TrainDemo.services.users;
import java.util.List;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Set; import java.util.Set;
import org.springframework.beans.factory.annotation.Autowired;
import org.slf4j.Logger;
import edu.drexel.TrainDemo.models.Group; import edu.drexel.TrainDemo.models.Group;
import edu.drexel.TrainDemo.models.GroupType; import edu.drexel.TrainDemo.models.GroupType;
import edu.drexel.TrainDemo.repositories.GroupRepository; import edu.drexel.TrainDemo.repositories.GroupRepository;
public class GroupServiceImpl implements GroupServices public class GroupServiceImpl implements GroupService
{ {
@Autowired
private Logger logger;
@Autowired
GroupRepository groupRepository; GroupRepository groupRepository;
public void GroupServiceImpl(GroupRepository groupRepository) @Override
public List<Group> getGroups()
{ {
this.groupRepository = groupRepository; List<Group> allGroups = new ArrayList<>();
this.groupRepository.findAll().forEach(allGroups::add);
return allGroups;
} }
public ArrayList<Group> listGroup(GroupType groupType) // public List<Group> listGroup(GroupType groupType)
{ // {
return groupRepository.findByType(groupType); // return groupRepository.findByType(groupType);
} // }
public ArrayList<Group> listGroupByIds(Set<Integer> groupId) // public List<Group> listGroupByIds(Set<Integer> groupId)
{ // {
return groupRepository.findByIds(groupId); // return groupRepository.findByIds(groupId);
} // }
public ArrayList<Group> listGroupByNames(ArrayList<String> name) // public List<Group> listGroupByNames(List<String> name)
{ // {
return groupRepository.findByNames(name); // return groupRepository.findByNames(name);
} // }
public Group findByName(String groupName) public Group findByName(String groupName)
{ {
return groupRepository.findByGroupName(groupName); return groupRepository.findByGroupName(groupName);
} }
} // End of GroupServicesImpl /* @Override
public Group createGroup(String groupId, String groupName, GroupType groupType) {
Group newGroup = new Group(groupName, groupId, groupType);
System.out.println("createGroup: " + newGroup.getGroupId() + " | " + newGroup.getGroupName() + " | " + newGroup.getGroupType());
this.groupRepository.save(newGroup);
return newGroup;
}
*/ */
} // End of GroupServicesImpl.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment