Skip to content

Commit

Permalink
Panchenko. Added java-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
KostyantynPanchenko committed Oct 27, 2016
1 parent 58cf98f commit c7f4460
Show file tree
Hide file tree
Showing 8 changed files with 183 additions and 11 deletions.
27 changes: 27 additions & 0 deletions src/com/softserve/museum/dao/impl/AbstractDAO.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,35 @@
@Transactional
public abstract class AbstractDAO<T, ID extends Serializable> implements GenericDAO<T, ID> {

/** SessionFactory objcet */
@Autowired
protected SessionFactory sessionFactory;

/** entity class */
private Class<T> entityClass;

/**
* Constructor.
* @param entityClass entity class
*/
protected AbstractDAO(Class<T> entityClass) {
this.entityClass = entityClass;
}

/**
* Finds object by its id.
* @param id object's id
* @return instance of type T
*/
@SuppressWarnings("unchecked")
@Override
public T findById(ID id) {
return (T) sessionFactory.getCurrentSession().get(entityClass, id);
}

/**
* @return all instances of given type T.
*/
@SuppressWarnings("unchecked")
@Override
public List<T> getAll() {
Expand All @@ -57,18 +71,31 @@ public List<T> getAll() {
return criteria.list();
}

/**
* Persists given entity of type T.
* @param entity instance of type T to be persisted.
* @return ID of persisted entity.
*/
@SuppressWarnings("unchecked")
@Override
public ID save(T entity) {
return (ID) sessionFactory.getCurrentSession().save(entity);
}

/**sates given instance of type T.
* @param entity instance to be updated.
* @return persisted entity.
*/
@SuppressWarnings("unchecked")
@Override
public T update(T entity) {
return (T) sessionFactory.getCurrentSession().merge(entity);
}

/**
* Deletes given entity of type T.
* @param entity to be deleted.
*/
@Override
public void delete(T entity) {
sessionFactory.getCurrentSession().delete(entity);
Expand Down
7 changes: 6 additions & 1 deletion src/com/softserve/museum/service/ExhibitService.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public interface ExhibitService {

/**
* Makes given instance persisted.
* @param exhibit instane to be persisted
* @param exhibit instance to be persisted
* @return persisted instance
*/
public abstract Integer save(Exhibit exhibit);
Expand Down Expand Up @@ -80,6 +80,11 @@ public interface ExhibitService {
*/
public abstract List<Exhibit> findExhibitByMaterial(String material);

/**
* Finds exhibits by given Materials' names.
* @param chosenMaterials Materials' names to search upon
* @return list of exhibits
*/
public abstract List<Exhibit> findExhibitByMaterials(String[] chosenMaterials);

/**
Expand Down
44 changes: 44 additions & 0 deletions src/com/softserve/museum/service/impl/ExcursionServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,32 @@ public class ExcursionServiceImpl implements ExcursionService {
@Autowired
private ExcursionDetailsDAO details;

/**
* Lists all excursions
* @return all excursions
*/
@Override
public List<ExcursionDetails> listExcursions() {
return details.getAll();
}

/**
* Finds excursions which are available in given time slot.
* @param start start of time slot
* @param end end of time slot
* @return list of Excursion objects
*/
@Override
public List<Excursion> findByTimeSlot(LocalDateTime start, LocalDateTime end) {
return excursions.findByTimeSlot(start, end);
}

/**
* Finds excursions which are available in given time slot.
* @param start start of time slot
* @param end end of time slot
* @return list of Excursion objects
*/
@Override
public List<Excursion> findByTimeSlot(String start, String end) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
Expand All @@ -57,31 +73,59 @@ public List<Excursion> findByTimeSlot(String start, String end) {
return excursions.findByTimeSlot(startTime, endTime);
}

/**
* Finds all excursions which start after given time.
* @param start start of time slot
* @return list of Excursion objects
*/
@Override
public List<Excursion> findByStart(LocalDateTime start) {
return excursions.findByStart(start);
}

/**
* Finds all excursions which start after given time.
* @param end end of time slot
* @return list of Excursion objects
*/
@Override
public List<Excursion> findByEnd(LocalDateTime end) {
return excursions.findByEnd(end);
}

/**
* Makes given Excursion instance persistent.
* @param excursion instance to be persisted
* @return generated id
*/
@Override
public Integer save(Excursion excursion) {
return excursions.save(excursion);
}

/**
* Updates given Excursion instance.
* @param excursion instance to be updated
* @return updated instance
*/
@Override
public Excursion update(Excursion excursion) {
return excursions.update(excursion);
}

/**
* Deletes given instance.
* @param excursion instance to be deleted
*/
@Override
public void delete(Excursion excursion) {
excursions.delete(excursion);
}

/**
* Lists all excursions
* @return all excursions
*/
@Override
public List<Excursion> listSchedule() {
return excursions.getAll();
Expand Down
58 changes: 58 additions & 0 deletions src/com/softserve/museum/service/impl/ExhibitServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,30 @@ public class ExhibitServiceImpl implements ExhibitService {
@Autowired
private TechniqueDAO techniques;

/**
* Finds all exhibits.
* @return list of all exhibits
*/
@Override
public List<Exhibit> listExhibits() {
return exhibits.getAll();
}

/**
* Finds exhibits by given Author.
* @param author Author instance to search upon
* @return list of exhibits
*/
@Override
public List<Exhibit> findExhibitByAuthor(Author author) {
return exhibits.findExhibitByAuthor(author);
}

/**
* Finds exhibits by given Author's name.
* @param author Author's name to search upon
* @return list of exhibits
*/
@Override
public List<Exhibit> findExhibitByAuthor(String author) {
List<Author> list = authors.findAuthorByName(author);
Expand All @@ -67,11 +81,21 @@ public List<Exhibit> findExhibitByAuthor(String author) {
return exhibits.findExhibitByAuthor(list.get(0));
}

/**
* Finds exhibits by given Material.
* @param material Material instance to search upon
* @return list of exhibits
*/
@Override
public List<Exhibit> findExhibitByMaterial(Material material) {
return exhibits.findExhibitByMaterial(material);
}

/**
* Finds exhibits by given Material's name.
* @param material Material's name to search upon
* @return list of exhibits
*/
@Override
public List<Exhibit> findExhibitByMaterial(String material) {
List<Material> list = materials.findMaterialByName(material);
Expand All @@ -81,6 +105,11 @@ public List<Exhibit> findExhibitByMaterial(String material) {
return exhibits.findExhibitByMaterial(list.get(0));
}

/**
* Finds exhibits by given Materials' names.
* @param chosenMaterials Materials' names to search upon
* @return list of exhibits
*/
@Override
public List<Exhibit> findExhibitByMaterials(String[] chosenMaterials) {
List<Material> list = new ArrayList<>();
Expand All @@ -92,11 +121,21 @@ public List<Exhibit> findExhibitByMaterials(String[] chosenMaterials) {
return exhibits.findExhibitByMaterials(list);
}

/**
* Finds exhibits by given Technique.
* @param material Technique instance to search upon
* @return list of exhibits
*/
@Override
public List<Exhibit> findExhibitByTechnique(Technique technique) {
return exhibits.findExhibitByTechnique(technique);
}

/**
* Finds exhibits by given Technique's name.
* @param material Technique name to search upon
* @return list of exhibits
*/
@Override
public List<Exhibit> findExhibitByTechniquel(String technique) {
List<Technique> list = techniques.findTechniqueByName(technique);
Expand All @@ -106,21 +145,40 @@ public List<Exhibit> findExhibitByTechniquel(String technique) {
return exhibits.findExhibitByTechnique(list.get(0));
}

/**
* Finds all exhibits by hall number.
* @param hallNumber given hall's number
* @return list of exhibits
*/
@Override
public List<Exhibit> findExhibitByHall(Integer hallNumber) {
return exhibits.findExhibitByHall(hallNumber);
}

/**
* Makes given instance persisted.
* @param exhibit instance to be persisted
* @return persisted instance
*/
@Override
public Integer save(Exhibit exhibit) {
return exhibits.save(exhibit);
}

/**
* Updates given instance.
* @param exhibit instance to be updated
* @return updated instance
*/
@Override
public Exhibit update(Exhibit exhibit) {
return exhibits.update(exhibit);
}

/**
* Deletes given instance.
* @param exhibit instance to be deleted
*/
@Override
public void delete(Exhibit exhibit) {
exhibits.delete(exhibit);
Expand Down
35 changes: 35 additions & 0 deletions src/com/softserve/museum/service/impl/GuideServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,21 @@ public class GuideServiceImpl implements GuideService {
@Autowired
private ExcursionDAO excursions;

/**
* Finds all guides.
* @return list of all guides
*/
@Override
public List<Guide> listGuides() {
return guides.getAll();
}

/**
* Finds all guides in given time slot.
* @param start start of time slot
* @param end end of time slot
* @return list of guides
*/
@Override
public List<Guide> findByTime(LocalDateTime start, LocalDateTime end) {
List<Excursion> eList = excursions.findInPeriod(start, end);
Expand All @@ -58,6 +68,12 @@ public List<Guide> findByTime(LocalDateTime start, LocalDateTime end) {
}


/**
* Finds all guides in given time slot.
* @param start start of time slot
* @param end end of time slot
* @return list of guides
*/
@Override
public List<Guide> findByTime(String start, String end) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
Expand All @@ -79,21 +95,40 @@ public List getCountTotalTimePerGuideByPeriod(LocalDateTime start, LocalDateTime
return guides.getCountTotalTimePerGuideByPeriod(start, end);
}

/**
* Makes given guide persistent.
* @param guide instance to be persisted
* @return guide's id
*/
@Override
public Integer save(Guide guide) {
return guides.save(guide);
}

/**
* Updates given instance.
* @param guide instance to be persisted
* @return updated instance
*/
@Override
public Guide update(Guide guide) {
return guides.update(guide);
}

/**
* Deleted given instance.
* @param guide instance to be deleted
*/
@Override
public void delete(Guide guiden) {
guides.delete(guiden);
}

/**
* Finds guide by given position.
* @param position guide's position
* @return list of guides
*/
@Override
public List<Guide> findByPosition(String position) {
Position thePosition;
Expand Down
Loading

0 comments on commit c7f4460

Please sign in to comment.