Notes![what is notes.io? What is notes.io?](/theme/images/whatisnotesio.png)
![]() ![]() Notes - notes.io |
* Copyright 2006-2021 HighRadius Corporation
*/
package com.highradius.g4.service.redline.dao;
import static com.highradius.g4.service.redline.config.REDLINEDB.REDLINE_PU;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import org.springframework.stereotype.Repository;
import com.highradius.g4.core.common.G4Log;
import com.highradius.g4.core.common.G4LogManager;
import com.highradius.g4.redline.entity.ClosingUnit;
import com.highradius.g4.redline.entity.FiscalCalendar;
import com.highradius.g4.redline.entity.FiscalCalendarYear;
import com.highradius.g4.redline.entity.MapClosingUnitFiscalCalendar;
/**
* The Class FiscalCalendarDAO.
*
* @author sourav.m.
*/
@Repository
public class FiscalCalendarDAO {
/** The Constant LOGGER. */
private static final G4Log LOGGER = G4LogManager.getLog(FiscalCalendarDAO.class);
/** The Redline entity manager. */
@PersistenceContext(unitName = REDLINE_PU)
private EntityManager redlineEntityManager;
/**
* Gets the fiscal calendars.
*
* @param limit the limit
* @param offset the offset
* @param accountId the account id
* @return the fiscal calendars
*/
public List<FiscalCalendar> getFiscalCalendars(Integer limit, Integer offset, Long accountId) {
LOGGER.debug("Getting all FiscalCalendars");
return redlineEntityManager
.createQuery("from FiscalCalendar where accountId = :accountId order by updateDate desc",
FiscalCalendar.class)
.setParameter("accountId", accountId).setFirstResult(offset).setMaxResults(limit).getResultList();
}
/**
* Gets the fiscal calendar.
*
* @param fiscalCalendar the fiscal calendar
* @param accountId the account id
* @return the fiscal calendar
*/
public FiscalCalendar getFiscalCalendar(Long fiscalCalendar, Long accountId) {
LOGGER.debug("Getting FiscalCalendar from id");
return redlineEntityManager
.createQuery("from FiscalCalendar where pkFiscalCalendar = :fiscalCalendar and accountId = :accountId",
FiscalCalendar.class)
.setParameter("fiscalCalendar", fiscalCalendar).setParameter("accountId", accountId).getSingleResult();
}
/**
* Save fiscal calendar.
*
* @param fiscalCalendar the fiscalCalendar
* @param userName the user name
* @param accountId the account id
* @return the fiscal calendar
*/
public FiscalCalendar saveFiscalCalendar(FiscalCalendar fiscalCalendar, String userName, Long accountId) {
LOGGER.debug("Saving FiscalCalendar");
redlineEntityManager.persist(fiscalCalendar);
return fiscalCalendar;
}
/**
* Find fiscal calendar.
*
* @param fiscalCalendar the fiscal calendar
* @return the fiscal calendar
*/
public FiscalCalendar findFiscalCalendar(Long fiscalCalendar) {
LOGGER.debug("Finding FiscalCalendar");
return redlineEntityManager.find(FiscalCalendar.class, fiscalCalendar);
}
/**
* Update fiscal calendar.
*
* @param fiscalCalendar the fiscal calendar
* @return the fiscal calendar
*/
public FiscalCalendar updateFiscalCalendar(FiscalCalendar fiscalCalendar) {
LOGGER.debug("Updating FiscalCalendar");
redlineEntityManager.persist(fiscalCalendar);
return fiscalCalendar;
}
/**
* Gets the map closing unit fiscal calendars.
*
* @param fiscalCalendarIds the fiscal calendar ids
* @param accountId the account id
* @return the map closing unit fiscal calendars
*/
public List<MapClosingUnitFiscalCalendar> getMapClosingUnitFiscalCalendars(List<Long> fiscalCalendarIds,
Integer accountId) {
LOGGER.debug("Inside getMapClosingUnitFiscalCalendars");
return redlineEntityManager.createQuery(
"from MapClosingUnitFiscalCalendar where fiscalCalendarId.pkFiscalCalendar in (:fiscalCalendarIds) and fiscalCalendarId.accountId = :accountId and isDeleted=1",
MapClosingUnitFiscalCalendar.class).setParameter("fiscalCalendarIds", fiscalCalendarIds)
.setParameter("accountId", accountId).getResultList();
}
/**
* Gets the closing unit.
*
* @param closingUnit the closing unit
* @return the closing unit
*/
public ClosingUnit getClosingUnit(Long closingUnit) {
LOGGER.debug("Inside getClosingUnit");
return redlineEntityManager.find(ClosingUnit.class, closingUnit);
}
/**
* Save map closing unit fiscal calendar.
*
* @param mapClosingUnitFiscalCalendar the map closing unit fiscal calendar
* @return the map closing unit fiscal calendar
*/
public MapClosingUnitFiscalCalendar saveMapClosingUnitFiscalCalendar(
MapClosingUnitFiscalCalendar mapClosingUnitFiscalCalendar) {
LOGGER.debug("Inside saveMapClosingUnitFiscalCalendar");
redlineEntityManager.persist(mapClosingUnitFiscalCalendar);
return mapClosingUnitFiscalCalendar;
}
/**
* Gets the fiscal calendar year.
*
* @param fiscalCalendar the fiscal calendar id
* @param accountId the account id
* @return the fiscal calendar year
*/
public FiscalCalendarYear getFiscalCalendarYear(Long fiscalCalendar, Long accountId) {
LOGGER.debug("Inside getFiscalCalendarYear");
return redlineEntityManager.createQuery(
"from FiscalCalendarYear where fiscalCalendar.pkFiscalCalendar =:fiscalCalendar and fiscalCalendar.accountId =:accountId",
FiscalCalendarYear.class).setParameter("fiscalCalendar", fiscalCalendar)
.setParameter("accountId", accountId).getSingleResult();
}
/**
* Save fiscal calendar year.
*
* @param fiscalCalendarYear the fiscal calendar year
* @return the fiscal calendar year
*/
public FiscalCalendarYear saveFiscalCalendarYear(FiscalCalendarYear fiscalCalendarYear) {
LOGGER.debug("Inside saveFiscalCalendarYear");
redlineEntityManager.persist(fiscalCalendarYear);
return fiscalCalendarYear;
}
/**
* Update fiscal calendar year.
*
* @param fiscalCalendarYear the fiscal calendar year
* @return the fiscal calendar year
*/
public FiscalCalendarYear updateFiscalCalendarYear(FiscalCalendarYear fiscalCalendarYear) {
LOGGER.debug("Updating FiscalCalendarYear");
redlineEntityManager.persist(fiscalCalendarYear);
return fiscalCalendarYear;
}
/**
* Gets the closing unit ids.
*
* @param fiscalCalendarId the fiscal calendar id
* @return the closing unit ids
*/
public List<MapClosingUnitFiscalCalendar> getClosingUnitIds(Long fiscalCalendarId) {
LOGGER.debug("Inside getClosingUnitIds");
return redlineEntityManager.createQuery(
"from MapClosingUnitFiscalCalendar where fiscalCalendar.pkFiscalCalendar=:fiscalCalendarId and closingUnit.isDeleted=0 and isDeleted=0 group by closingUnit",
MapClosingUnitFiscalCalendar.class).setParameter("fiscalCalendarId", fiscalCalendarId).getResultList();
}
/**
* Gets the already mapped closing unit id.
*
* @return the already mapped closing unit id
*/
public List<Long> getAllMappedClosingUnitId() {
LOGGER.debug("Inside getAllMappedClosingUnitId");
return redlineEntityManager.createQuery(
"select closingUnit.pkClosingUnitId from MapClosingUnitFiscalCalendar where closingUnit.isDeleted=0",
Long.class).getResultList();
}
/**
* Gets the with out mapped.
*
* @return the with out mapped
*/
public List<Long> getAllClosingUnits() {
LOGGER.debug("Inside getAllClosingUnits");
return redlineEntityManager.createQuery("select pkClosingUnitId from ClosingUnit", Long.class).getResultList();
}
/**
* Fetch already mapped.
*
* @param closingUnitIds the closing unit ids
* @return the map closing unit fiscal calendar
*/
public List<MapClosingUnitFiscalCalendar> fetchMappedByUsers(List<Long> closingUnitIds) {
LOGGER.debug("Inside fetchMappedByUsers");
return redlineEntityManager.createQuery(
"from MapClosingUnitFiscalCalendar where closingUnit.pkClosingUnitId in (:closingUnitIds) and isDeleted=0",
MapClosingUnitFiscalCalendar.class).setParameter("closingUnitIds", closingUnitIds).getResultList();
}
/**
* Handle is default.
*
* @param fiscalCalendarId the fiscal calendar id
* @return the long
*/
public Long handleIsDefault(Long fiscalCalendarId) {
LOGGER.debug("Inside handleIsDefault");
redlineEntityManager
.createQuery("update FiscalCalendar set isDefault=0 where pkFiscalCalendar !=:fiscalCalendarId")
.setParameter("fiscalCalendarId", fiscalCalendarId).executeUpdate();
return fiscalCalendarId;
}
/**
* Gets the total fiscal calendar count.
*
* @return the total fiscal calendar count
*/
public Long getTotalFiscalCalendarCount() {
LOGGER.debug("Inside getTotalFiscalCalendarCount");
return redlineEntityManager.createQuery("Select COUNT(*) from FiscalCalendar", Long.class).getSingleResult();
}
/**
* Gets the total fiscal calendar is active count.
*
* @return the total fiscal calendar is active count
*/
public Long getTotalFiscalCalendarIsActiveCount() {
LOGGER.debug("Inside getTotalFiscalCalendarIsActiveCount");
return redlineEntityManager.createQuery("Select COUNT(*) from FiscalCalendar where isActive=1", Long.class)
.getSingleResult();
}
/**
* Search fiscal calendar.
*
* @param searchKeyword the searchKeyword
* @return the list
*/
public List<FiscalCalendar> searchFiscalCalendars(String searchKeyword) {
LOGGER.debug("Inside searchFiscalCalendars");
String sqlQuery = "from FiscalCalendar where (fiscalCalendarName like :fiscalCalendarName)";
sqlQuery += " order by updateDate DESC";
return redlineEntityManager.createQuery(sqlQuery, FiscalCalendar.class)
.setParameter("fiscalCalendarName", "%" + searchKeyword + "%").getResultList();
}
}
![]() |
Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 12 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team