List of usage examples for org.springframework.dao.support DataAccessUtils singleResult
@Nullable public static <T> T singleResult(@Nullable Collection<T> results) throws IncorrectResultSizeDataAccessException
From source file:org.apereo.portal.RDBMUserIdentityStore.java
public String getPortalUserName(final int uPortalUID) { final List<String> results = this.jdbcOperations .queryForList("SELECT USER_NAME FROM UP_USER WHERE USER_ID=?", String.class, uPortalUID); return DataAccessUtils.singleResult(results); }
From source file:org.apereo.portal.RDBMUserIdentityStore.java
@Override public Integer getPortalUserId(String userName) { final List<Integer> results = this.jdbcOperations .queryForList("SELECT USER_ID FROM UP_USER WHERE USER_NAME=?", Integer.class, userName); return DataAccessUtils.singleResult(results); }
From source file:org.jasig.portal.io.xml.JaxbPortalDataHandlerService.java
protected final void importData(final Source source, PortalDataKey portalDataKey) { //Get a StAX reader for the source to determine info about the data to import final BufferedXMLEventReader bufferedXmlEventReader = createSourceXmlEventReader(source); //If no PortalDataKey was passed build it from the source if (portalDataKey == null) { final StartElement rootElement = StaxUtils.getRootElement(bufferedXmlEventReader); portalDataKey = new PortalDataKey(rootElement); bufferedXmlEventReader.reset();//from ww w . j ava 2 s . c o m } final String systemId = source.getSystemId(); //Post Process the PortalDataKey to see if more complex import operations are needed final IPortalDataType portalDataType = this.dataKeyTypes.get(portalDataKey); if (portalDataType == null) { throw new RuntimeException("No IPortalDataType configured for " + portalDataKey + ", the resource will be ignored: " + getPartialSystemId(systemId)); } final Set<PortalDataKey> postProcessedPortalDataKeys = portalDataType.postProcessPortalDataKey(systemId, portalDataKey, bufferedXmlEventReader); bufferedXmlEventReader.reset(); //If only a single result from post processing import if (postProcessedPortalDataKeys.size() == 1) { this.importOrUpgradeData(systemId, DataAccessUtils.singleResult(postProcessedPortalDataKeys), bufferedXmlEventReader); } //If multiple results from post processing ordering is needed else { //Iterate over the data key order list to run the imports in the correct order for (final PortalDataKey orderedPortalDataKey : this.dataKeyImportOrder) { if (postProcessedPortalDataKeys.contains(orderedPortalDataKey)) { //Reset the to start of the XML document for each import/upgrade call bufferedXmlEventReader.reset(); this.importOrUpgradeData(systemId, orderedPortalDataKey, bufferedXmlEventReader); } } } }
From source file:org.linagora.linshare.core.service.impl.WorkGroupFolderServiceImpl.java
private WorkGroupFolder getRootFolder(Thread workGroup) { WorkGroupFolder wgfParent = null;//from www . j av a 2 s .c om String workGroupUuid = workGroup.getLsUuid(); wgfParent = DataAccessUtils.singleResult(repository.findByWorkGroupAndParent(workGroupUuid, workGroupUuid)); if (wgfParent == null) { // creation of the root folder. wgfParent = new WorkGroupFolder(workGroup.getName(), workGroupUuid, workGroupUuid); wgfParent = repository.insert(wgfParent); } return wgfParent; }
From source file:org.ojbc.adapters.analyticaldatastore.dao.AnalyticalDatastoreDAOImpl.java
@Override public PretrialServiceParticipation searchForPretrialServiceParticipationByUniqueID(String uniqueID) { List<PretrialServiceParticipation> pretrialServiceParticipations = jdbcTemplate.query( PRETRIAL_SERVICE_PARTICIPATION_BY_UNIQUE_ID, new PretrialServiceParticipationRowMapper(), uniqueID); return DataAccessUtils.singleResult(pretrialServiceParticipations); }
From source file:org.ojbc.adapters.analyticaldatastore.dao.AnalyticalDatastoreDAOImpl.java
@Override public Person getPerson(Integer personId) { List<Person> persons = jdbcTemplate.query(PERSON_SELECT, new PersonRowMapper(), personId); return DataAccessUtils.singleResult(persons); }
From source file:org.ojbc.adapters.analyticaldatastore.dao.AnalyticalDatastoreDAOImpl.java
@Override public Integer searchForAgenyIDbyAgencyORI(String agencyORI) { String sql = "select * from Agency where AgencyORI = ?"; List<Agency> agencies = jdbcTemplate.query(sql, new AgencyRowMapper(), agencyORI); Agency agency = DataAccessUtils.singleResult(agencies); if (agency == null) { return null; }//from w w w. j a v a 2s .c o m return agency.getAgencyID(); }
From source file:org.ojbc.adapters.analyticsstaging.custody.dao.AnalyticalDatastoreDAOImpl.java
@Override public Person getPerson(Integer personId) { final String PERSON_SELECT = "SELECT * FROM Person p " + "LEFT JOIN PersonSexType s ON s.PersonSexTypeID = p.PersonSexTypeID " + "LEFT JOIN PersonRaceType r ON r.PersonRaceTypeID = p.PersonRaceTypeID " + "LEFT JOIN PersonEthnicityType pet ON pet.PersonEthnicityTypeID = p.PersonEthnicityTypeID " + "LEFT JOIN LanguageType l on l.languageTypeID = p.languageTypeID " + "LEFT JOIN DomicileStatusType h ON h.DomicileStatusTypeID = p.DomicileStatusTypeID " + "LEFT JOIN WorkReleaseStatusType w on w.WorkReleaseStatusTypeID = p.WorkReleaseStatusTypeID " + "LEFT JOIN ProgramEligibilityType pe on pe.ProgramEligibilityTypeID = p.ProgramEligibilityTypeID " + "LEFT JOIN MilitaryServiceStatusType m on m.MilitaryServiceStatusTypeID = p.MilitaryServiceStatusTypeID " + "WHERE p.PersonID = ?"; List<Person> persons = jdbcTemplate.query(PERSON_SELECT, new PersonRowMapper(), personId); return DataAccessUtils.singleResult(persons); }
From source file:org.ojbc.adapters.analyticsstaging.custody.dao.AnalyticalDatastoreDAOImpl.java
@Override public Booking getBookingByBookingNumber(String bookingNumber) { final String sql = "SELECT * FROM Booking b " + "WHERE bookingNumber = ?"; List<Booking> bookings = jdbcTemplate.query(sql, new BookingRowMapper(), bookingNumber); return DataAccessUtils.singleResult(bookings); }
From source file:org.ojbc.adapters.analyticsstaging.custody.dao.AnalyticalDatastoreDAOImpl.java
@Override public CustodyRelease getCustodyReleaseByBookingId(Integer bookingId) { final String sql = "Select top 1 * from CustodyRelease where BookingId = ? order by CustodyReleaseTimestamp desc"; List<CustodyRelease> custodyReleases = jdbcTemplate.query(sql, new CustodyReleaseRowMapper(), bookingId); return DataAccessUtils.singleResult(custodyReleases); }