method2testcases
stringlengths
118
6.63k
### Question: ModuleLifecycleContextImpl implements ModuleLifecycleContext { @Override public void registerModuleObservingComponent(String nodeName, ObservedManager component) { if (components.containsKey(nodeName)) { final Object currentObservedManager = components.get(nodeName); throw new IllegalStateException("Obser...
### Question: AbstractModuleVersionHandler implements ModuleVersionHandler { protected void register(Delta delta) { final Version v = delta.getVersion(); if (allDeltas.containsKey(v)) { throw new IllegalStateException("Version " + v + " was already registered in this ModuleVersionHandler."); } delta.getTasks().addAll(g...
### Question: AbstractModuleVersionHandler implements ModuleVersionHandler { @Override public List<Delta> getDeltas(InstallContext installContext, Version from) { if (from == null) { return Collections.singletonList(getInstall(installContext)); } return getUpdateDeltas(installContext, from); } AbstractModuleVersionHand...
### Question: ModuleRegistryImpl implements ModuleRegistry { @Override public List<ModuleDefinition> getModuleDefinitions() { final List<ModuleDefinition> defs = new ArrayList<ModuleDefinition>(); for (ModuleEntry mod : entries.values()) { defs.add(mod.moduleDefinition); } return Collections.unmodifiableList(defs); } M...
### Question: RenameACLNodesTask extends AbstractRepositoryTask { public RenameACLNodesTask() { super("Security", "Renames ACL nodes."); } RenameACLNodesTask(); }### Answer: @Test public void testRenameACLNodesTask() throws Exception { Session session = MgnlContext.getSystemContext().getJCRSession(RepositoryConstants...
### Question: BasePatternVoter extends AbstractBoolVoter { public void init() { if(autoTrueValue){ if(!isInverse()){ setTrueValue(pattern.length()); } else{ setTrueValue(-pattern.length()); } } } void init(); @Override void setTrueValue(int positiveVoteValue); String getPattern(); void setPattern(String pattern); bool...
### Question: ResponseContentTypeVoter extends AbstractBoolVoter { public void addAllowed(String contentType) { allowed.add(contentType); } List<String> getAllowed(); void setAllowed(List<String> allowed); void addAllowed(String contentType); List<String> getRejected(); void setRejected(List<String> rejected); void ad...
### Question: ResponseContentTypeVoter extends AbstractBoolVoter { public void addRejected(String contentType) { rejected.add(contentType); } List<String> getAllowed(); void setAllowed(List<String> allowed); void addAllowed(String contentType); List<String> getRejected(); void setRejected(List<String> rejected); void ...
### Question: URIPatternVoter extends BasePatternVoter { @Override public void setPattern(String pattern) { super.setPattern(pattern); this.pattern = new SimpleUrlPattern(pattern); } @Override void setPattern(String pattern); }### Answer: @Test public void testVotesTrueOnMatchingWildcardPattern() { URIPatternVoter vo...
### Question: FreemarkerHelper { public void render(String templatePath, Object root, Writer out) throws TemplateException, IOException { render(templatePath, null, null, root, out); } FreemarkerHelper(); FreemarkerHelper(final FreemarkerConfig freemarkerConfig); static FreemarkerHelper getInstance(); void resetObject...
### Question: FreemarkerHelper { public static FreemarkerHelper getInstance() { return Components.getSingleton(FreemarkerHelper.class); } FreemarkerHelper(); FreemarkerHelper(final FreemarkerConfig freemarkerConfig); static FreemarkerHelper getInstance(); void resetObjectWrapper(); void render(String templatePath, Obj...
### Question: MagnoliaObjectWrapper extends DefaultObjectWrapper { @Override public TemplateModel wrap(Object obj) throws TemplateModelException { if (obj == null) { return super.wrap(null); } if ((obj instanceof Class) && ((Class) obj).isEnum()) { final String enumClassName = ((Class) obj).getName(); return getEnumMod...
### Question: TemplatingFunctions { public Property inheritProperty(Node content, String relPath) throws RepositoryException { if (content == null) { return null; } if (StringUtils.isBlank(relPath)) { throw new IllegalArgumentException("relative path cannot be null or empty"); } try { Node inheritedNode = wrapForInheri...
### Question: TemplatingFunctions { public String language(){ return I18nContentSupportFactory.getI18nSupport().getLocale().toString(); } @Inject TemplatingFunctions(Provider<AggregationState> aggregationStateProvider); Node asJCRNode(ContentMap contentMap); ContentMap asContentMap(Node content); List<Node> children(N...
### Question: TemplatingFunctions { public String externalLink(Node content, String linkPropertyName) { String externalLink = PropertyUtil.getString(content, linkPropertyName); if (StringUtils.isBlank(externalLink)) { return StringUtils.EMPTY; } if (!hasProtocol(externalLink)) { externalLink = "http: } return externalL...
### Question: TemplatingFunctions { public String externalLinkTitle(Node content, String linkPropertyName, String linkTitlePropertyName) { String linkTitle = PropertyUtil.getString(content, linkTitlePropertyName); if (StringUtils.isNotEmpty(linkTitle)) { return linkTitle; } return externalLink(content, linkPropertyName...
### Question: TemplatingFunctions { public List<Node> asNodeList(Collection<ContentMap> contentMapList) { if (contentMapList != null) { List<Node> nodeList = new ArrayList<Node>(); for (ContentMap node : contentMapList) { nodeList.add(node.getJCRNode()); } return nodeList; } return null; } @Inject TemplatingFunctions(...
### Question: TemplatingFunctions { public List<ContentMap> asContentMapList(Collection<Node> nodeList) { if (nodeList != null) { List<ContentMap> contentMapList = new ArrayList<ContentMap>(); for (Node node : nodeList) { contentMapList.add(asContentMap(node)); } return contentMapList; } return null; } @Inject Templat...
### Question: EmailNotificationSender implements NotificationSender { @Override public NotificationMedium getNotificationMedium() { return EMAIL; } @Override NotificationMedium getNotificationMedium(); @Override ServiceResult<Notification> sendNotification(Notification notification); @Override @Transactional(propagati...
### Question: InterviewInviteController { @DeleteMapping("/delete-invite") public RestResult<Void> deleteInvite(@RequestParam String email, @RequestParam long competitionId) { return interviewInviteService.deleteInvite(email, competitionId).toDeleteResponse(); } @GetMapping("/get-all-invites-to-send/{competitionId}") ...
### Question: InterviewInviteController { @DeleteMapping("/delete-all-invites") public RestResult<Void> deleteAllInvites(@RequestParam long competitionId) { return interviewInviteService.deleteAllInvites(competitionId).toDeleteResponse(); } @GetMapping("/get-all-invites-to-send/{competitionId}") RestResult<AssessorInv...
### Question: InterviewApplicationFeedbackServiceImpl implements InterviewApplicationFeedbackService { @Override @Transactional(readOnly = true) public ServiceResult<FileEntryResource> findFeedback(long applicationId) { return findAssignmentByApplicationId(applicationId).andOnSuccess(interviewAssignment -> ofNullable(i...
### Question: InterviewApplicationFeedbackServiceImpl implements InterviewApplicationFeedbackService { @Override @Transactional(readOnly = true) public ServiceResult<FileAndContents> downloadFeedback(long applicationId) { return findAssignmentByApplicationId(applicationId).andOnSuccess(interviewAssignment -> fileEntryS...
### Question: InterviewApplicationFeedbackServiceImpl implements InterviewApplicationFeedbackService { @Override public ServiceResult<Void> deleteFeedback(long applicationId) { return findAssignmentByApplicationId(applicationId).andOnSuccess(interviewAssignment -> { long fileId = interviewAssignment.getMessage().getFee...
### Question: InterviewAllocationServiceImpl implements InterviewAllocationService { @Override public ServiceResult<InterviewAcceptedAssessorsPageResource> getInterviewAcceptedAssessors(long competitionId, Pageable pageable) { Page<InterviewAcceptedAssessorsResource> pagedResult = interviewParticipantRepository.getInte...
### Question: PublicContentServiceImpl extends BaseTransactionalService implements PublicContentService { @Override @Transactional public ServiceResult<Void> updateSection(PublicContentResource resource, PublicContentSectionType section) { return saveSection(resource, section).andOnSuccessReturnVoid(); } @Override Ser...
### Question: InterviewAllocationServiceImpl implements InterviewAllocationService { @Override public ServiceResult<InterviewApplicationPageResource> getAllocatedApplications(long competitionId, long assessorUserId, Pageable pageable) { Page<InterviewApplicationResource> pagedResult = interviewRepository.findApplicatio...
### Question: InterviewAllocationServiceImpl implements InterviewAllocationService { @Override public ServiceResult<List<InterviewResource>> getAllocatedApplicationsByAssessorId(long competitionId, long assessorUserId) { List<Interview> interviews = interviewRepository.findByParticipantUserIdAndTargetCompetitionIdOrder...
### Question: InterviewAllocationServiceImpl implements InterviewAllocationService { @Override public ServiceResult<InterviewApplicationPageResource> getUnallocatedApplications(long competitionId, long assessorUserId, Pageable pageable) { Page<InterviewApplicationResource> pagedResult = interviewRepository.findApplicat...
### Question: InterviewAllocationServiceImpl implements InterviewAllocationService { @Override public ServiceResult<List<Long>> getUnallocatedApplicationIds(long competitionId, long assessorId) { return serviceSuccess(interviewRepository.findApplicationIdsNotAssignedToAssessor(competitionId, assessorId)); } @Override ...
### Question: InterviewAllocationServiceImpl implements InterviewAllocationService { @Override public ServiceResult<AssessorInvitesToSendResource> getInviteToSend(long competitionId, long assessorId) { return getCompetition(competitionId).andOnSuccess( competition -> getUser(assessorId).andOnSuccess( user -> serviceSuc...
### Question: InterviewAllocationServiceImpl implements InterviewAllocationService { @Override @Transactional public ServiceResult<Void> notifyAllocation(InterviewNotifyAllocationResource interviewNotifyAllocationResource) { return getInterviewParticipant(interviewNotifyAllocationResource.getAssessorId(), interviewNoti...
### Question: InterviewAllocationServiceImpl implements InterviewAllocationService { @Override public ServiceResult<List<InterviewApplicationResource>> getUnallocatedApplicationsById(List<Long> applicationIds) { return serviceSuccess(interviewRepository.findAllNotified(applicationIds)); } @Override ServiceResult<Inter...
### Question: InterviewInviteServiceImpl extends InviteService<InterviewInvite> implements InterviewInviteService { @Override public ServiceResult<List<Long>> getAvailableAssessorIds(long competitionId) { List<AssessmentParticipant> result = assessmentParticipantRepository.findParticipantsNotOnInterviewPanel(competitio...
### Question: InterviewInviteServiceImpl extends InviteService<InterviewInvite> implements InterviewInviteService { @Override public ServiceResult<Void> deleteInvite(String email, long competitionId) { return getByEmailAndCompetition(email, competitionId).andOnSuccess(this::deleteInvite); } @Override ServiceResult<Ass...
### Question: InterviewInviteServiceImpl extends InviteService<InterviewInvite> implements InterviewInviteService { @Override public ServiceResult<Void> deleteAllInvites(long competitionId) { return find(competitionRepository.findById(competitionId), notFoundError(Competition.class, competitionId)) .andOnSuccessReturnV...
### Question: InterviewInviteServiceImpl extends InviteService<InterviewInvite> implements InterviewInviteService { @Override public ServiceResult<InterviewInviteResource> openInvite(String inviteHash) { return getByHashIfOpen(inviteHash) .andOnSuccessReturn(this::openInvite) .andOnSuccessReturn(interviewInviteMapper::...
### Question: InterviewInviteServiceImpl extends InviteService<InterviewInvite> implements InterviewInviteService { @Override public ServiceResult<Void> acceptInvite(String inviteHash) { return getParticipantByInviteHash(inviteHash) .andOnSuccess(InterviewInviteServiceImpl::accept) .andOnSuccessReturnVoid(); } @Overri...
### Question: InterviewResponseServiceImpl implements InterviewResponseService { @Override @Transactional(readOnly = true) public ServiceResult<FileEntryResource> findResponse(long applicationId) { return findAssignmentByApplicationId(applicationId).andOnSuccess(interviewAssignment -> ofNullable(interviewAssignment.get...
### Question: InterviewResponseServiceImpl implements InterviewResponseService { @Override @Transactional(readOnly = true) public ServiceResult<FileAndContents> downloadResponse(long applicationId) { return findAssignmentByApplicationId(applicationId).andOnSuccess(interviewAssignment -> fileEntryService.findOne(intervi...
### Question: InterviewResponseServiceImpl implements InterviewResponseService { @Override public ServiceResult<Void> deleteResponse(long applicationId) { return findAssignmentByApplicationId(applicationId).andOnSuccessReturnVoid(interviewAssignment -> interviewAssignmentWorkflowHandler.withdrawResponse(interviewAssign...
### Question: InterviewAssignmentServiceImpl implements InterviewAssignmentService { @Override @Transactional(readOnly = true) public ServiceResult<AvailableApplicationPageResource> getAvailableApplications(long competitionId, Pageable pageable) { final Page<Application> pagedResult = applicationRepository.findSubmitte...
### Question: InterviewAssignmentServiceImpl implements InterviewAssignmentService { @Override @Transactional(readOnly = true) public ServiceResult<InterviewAssignmentStagedApplicationPageResource> getStagedApplications(long competitionId, Pageable pageable) { final Page<InterviewAssignment> pagedResult = interviewAssi...
### Question: InterviewAssignmentServiceImpl implements InterviewAssignmentService { @Override @Transactional(readOnly = true) public ServiceResult<List<Long>> getAvailableApplicationIds(long competitionId) { return serviceSuccess( simpleMap( applicationRepository.findSubmittedApplicationsNotOnInterviewPanel(competitio...
### Question: InterviewAssignmentServiceImpl implements InterviewAssignmentService { @Override public ServiceResult<Void> assignApplications(List<StagedApplicationResource> stagedInvites) { stagedInvites.stream() .distinct() .map(invite -> getApplication(invite.getApplicationId())) .forEach(application -> assignApplica...
### Question: InterviewAssignmentServiceImpl implements InterviewAssignmentService { @Override public ServiceResult<Void> unstageApplication(long applicationId) { interviewAssignmentRepository.deleteByTargetIdAndActivityState(applicationId, CREATED); return serviceSuccess(); } @Override @Transactional(readOnly = true)...
### Question: InterviewAssignmentServiceImpl implements InterviewAssignmentService { @Override public ServiceResult<Void> unstageApplications(long competitionId) { interviewAssignmentRepository.deleteByTargetCompetitionIdAndActivityState(competitionId, CREATED); return serviceSuccess(); } @Override @Transactional(read...
### Question: InterviewAssignmentServiceImpl implements InterviewAssignmentService { @Override @Transactional(readOnly = true) public ServiceResult<Boolean> isApplicationAssigned(long applicationId) { return serviceSuccess(interviewAssignmentRepository.existsByTargetIdAndActivityStateIn(applicationId, asList(AWAITING_F...
### Question: InterviewApplicationInviteServiceImpl implements InterviewApplicationInviteService { @Override public ServiceResult<ApplicantInterviewInviteResource> getEmailTemplate() { NotificationTarget notificationTarget = new UserNotificationTarget("", ""); return renderer.renderTemplate(systemNotificationSource, no...
### Question: InterviewApplicationInviteServiceImpl implements InterviewApplicationInviteService { @Override public ServiceResult<Void> sendInvites(long competitionId, AssessorInviteSendResource assessorInviteSendResource) { List<InterviewAssignment> interviewAssignments = interviewAssignmentRepository.findByTargetComp...
### Question: InterviewApplicationInviteServiceImpl implements InterviewApplicationInviteService { @Override public ServiceResult<InterviewApplicationSentInviteResource> getSentInvite(long applicationId) { InterviewAssignment assignment = interviewAssignmentRepository.findOneByTargetId(applicationId); return ofNullable...
### Question: InterviewApplicationInviteServiceImpl implements InterviewApplicationInviteService { @Override public ServiceResult<Void> resendInvite(long applicationId, AssessorInviteSendResource assessorInviteSendResource) { InterviewAssignment assignment = interviewAssignmentRepository.findOneByTargetId(applicationId...
### Question: CompetitionInitialiser { public Competition initialiseFinanceTypes(Competition competition) { if (competition.getFundingType() == null) { return competition; } List<FinanceRowType> types; switch (competition.getFundingType()) { case LOAN: types = loanFinanceTypes(); break; case PROCUREMENT: types = procur...
### Question: CompetitionInitialiser { public Competition initialiseProjectSetupColumns(Competition competition) { if (competition.getFundingType() == null) { return competition; } switch (competition.getFundingType()) { case LOAN: addLoanProjectSetupColumns(competition); break; case PROCUREMENT: case GRANT: case KTP: ...
### Question: CompetitionSetupInnovationLeadController { @GetMapping("/{competitionId}/innovation-leads") public RestResult<List<UserResource>> findAvailableInnovationLeadsNotAssignedToCompetition(@PathVariable("competitionId") final long competitionId) { return competitionSetupInnovationLeadService.findInnovationLeads...
### Question: CompetitionSetupInnovationLeadController { @GetMapping("/{competitionId}/innovation-leads/find-added") public RestResult<List<UserResource>> findInnovationLeadsAddedToCompetition(@PathVariable("competitionId") final long competitionId) { return competitionSetupInnovationLeadService.findAddedInnovationLead...
### Question: CompetitionSetupInnovationLeadController { @PostMapping("/{competitionId}/add-innovation-lead/{innovationLeadUserId}") public RestResult<Void> addInnovationLead(@PathVariable("competitionId") final long competitionId, @PathVariable("innovationLeadUserId") final long innovationLeadUserId) { return competit...
### Question: CompetitionSetupInnovationLeadController { @PostMapping("/{competitionId}/remove-innovation-lead/{innovationLeadUserId}") public RestResult<Void> removeInnovationLead(@PathVariable("competitionId") final long competitionId, @PathVariable("innovationLeadUserId") final long innovationLeadUserId) { return co...
### Question: CompetitionSetupPostAwardServiceController { @PostMapping("/{competitionId}/post-award-service/{postAwardService}") public RestResult<Void> configurePostAwardService(@PathVariable("competitionId") final long competitionId, @PathVariable("postAwardService") final PostAwardService postAwardService) { return...
### Question: CompetitionSetupFinanceUserController { @PostMapping("/{competitionId}/finance-users/invite") public RestResult<Void> inviteCompetitionFinanceUser(@PathVariable("competitionId") final long competitionId, @RequestBody InviteUserResource inviteUserResource) { return competitionSetupFinanceUserService.invite...
### Question: CompetitionSetupFinanceUserController { @GetMapping("/{competitionId}/finance-users/find-all") public RestResult<List<UserResource>> findCompetitionFinanceUser(@PathVariable("competitionId") final long competitionId) { return competitionSetupFinanceUserService.findFinanceUser(competitionId).toGetResponse(...
### Question: CompetitionSetupFinanceUserController { @GetMapping("/get-finance-users-invite/{inviteHash}") public RestResult<CompetitionFinanceInviteResource> getInvite(@PathVariable("inviteHash") String inviteHash) { return competitionSetupFinanceUserService.getInviteByHash(inviteHash).toGetResponse(); } @PostMappin...
### Question: CompetitionSetupFinanceUserController { @PostMapping("/finance-users/create/{inviteHash}") public RestResult<Void> createCompetitionFinanceUser(@PathVariable("inviteHash") String inviteHash, @RequestBody CompetitionFinanceRegistrationResource competitionFinanceRegistrationResource) { return registrationSe...
### Question: CompetitionSetupFinanceUserController { @PostMapping("/{competitionId}/finance-users/{userId}/remove") public RestResult<Void> removeCompetitionFinanceUser(@PathVariable("competitionId") final long competitionId, @PathVariable("userId") final long userId) { return competitionSetupFinanceUserService.remove...
### Question: CompetitionSetupStakeholderController { @PostMapping("/{competitionId}/stakeholder/invite") public RestResult<Void> inviteStakeholder(@PathVariable("competitionId") final long competitionId, @RequestBody InviteUserResource inviteUserResource) { return competitionSetupStakeholderService.inviteStakeholder(i...
### Question: CompetitionSetupStakeholderController { @GetMapping("/{competitionId}/stakeholder/find-all") public RestResult<List<UserResource>> findStakeholders(@PathVariable("competitionId") final long competitionId) { return competitionSetupStakeholderService.findStakeholders(competitionId).toGetResponse(); } @Post...
### Question: CompetitionSetupStakeholderController { @GetMapping("/get-stakeholder-invite/{inviteHash}") public RestResult<StakeholderInviteResource> getInvite(@PathVariable("inviteHash") String inviteHash) { return competitionSetupStakeholderService.getInviteByHash(inviteHash).toGetResponse(); } @PostMapping("/{comp...
### Question: CompetitionSetupStakeholderController { @PostMapping("/{competitionId}/stakeholder/{stakeholderUserId}/add") public RestResult<Void> addStakeholder(@PathVariable("competitionId") final long competitionId, @PathVariable("stakeholderUserId") final long stakeholderUserId) { return competitionSetupStakeholder...
### Question: CompetitionSetupStakeholderController { @PostMapping("/{competitionId}/stakeholder/{stakeholderUserId}/remove") public RestResult<Void> removeStakeholder(@PathVariable("competitionId") final long competitionId, @PathVariable("stakeholderUserId") final long stakeholderUserId) { return competitionSetupStake...
### Question: CompetitionSetupStakeholderController { @GetMapping("/{competitionId}/stakeholder/pending-invites") public RestResult<List<UserResource>> findPendingStakeholderInvites(@PathVariable("competitionId") final long competitionId) { return competitionSetupStakeholderService.findPendingStakeholderInvites(competi...
### Question: CompetitionSetupFinanceServiceImpl extends BaseTransactionalService implements CompetitionSetupFinanceService { @Override @Transactional public ServiceResult<Void> save(CompetitionSetupFinanceResource compSetupFinanceRes) { return getCompetition(compSetupFinanceRes.getCompetitionId()).andOnSuccess...
### Question: CompetitionSetupFinanceServiceImpl extends BaseTransactionalService implements CompetitionSetupFinanceService { @Override public ServiceResult<CompetitionSetupFinanceResource> getForCompetition(long competitionId) { return getCompetition(competitionId).andOnSuccessReturn(this::buildCompetitionSetu...
### Question: CompetitionSetupStakeholderServiceImpl extends BaseTransactionalService implements CompetitionSetupStakeholderService { @Override public ServiceResult<List<UserResource>> findStakeholders(long competitionId) { List<Stakeholder> stakeholders = stakeholderRepository.findStakeholders(competitionId); List<Use...
### Question: CompetitionSetupStakeholderServiceImpl extends BaseTransactionalService implements CompetitionSetupStakeholderService { @Override @Transactional public ServiceResult<Void> addStakeholder(long competitionId, long stakeholderUserId) { return getCompetition(competitionId) .andOnSuccessReturnVoid(competition ...
### Question: CompetitionSetupStakeholderServiceImpl extends BaseTransactionalService implements CompetitionSetupStakeholderService { @Override @Transactional public ServiceResult<Void> removeStakeholder(long competitionId, long stakeholderUserId) { stakeholderRepository.deleteStakeholder(competitionId, stakeholderUser...
### Question: CompetitionSetupStakeholderServiceImpl extends BaseTransactionalService implements CompetitionSetupStakeholderService { @Override @Transactional public ServiceResult<List<UserResource>> findPendingStakeholderInvites(long competitionId) { List<StakeholderInvite> pendingStakeholderInvites = stakeholderInvit...
### Question: CompetitionSetupServiceImpl extends BaseTransactionalService implements CompetitionSetupService { @Override public ServiceResult<Map<CompetitionSetupSection, Optional<Boolean>>> getSectionStatuses(Long competitionId) { List<SetupStatusResource> setupStatuses = setupStatusService .findByTargetClassNameAndT...
### Question: CompetitionSetupServiceImpl extends BaseTransactionalService implements CompetitionSetupService { @Override @Transactional public ServiceResult<Void> copyFromCompetitionTypeTemplate(Long competitionId, Long competitionTypeId) { return competitionSetupTemplateService.initializeCompetitionByCompetitionTempl...
### Question: CompetitionSetupServiceImpl extends BaseTransactionalService implements CompetitionSetupService { @Override @Transactional public ServiceResult<Void> markAsSetup(Long competitionId) { Competition competition = competitionRepository.findById(competitionId).get(); competition.setSetupComplete(true); return ...
### Question: CompetitionSetupServiceImpl extends BaseTransactionalService implements CompetitionSetupService { @Override @Transactional public ServiceResult<Void> returnToSetup(Long competitionId) { Competition competition = competitionRepository.findById(competitionId).get(); competition.setSetupComplete(false); retu...
### Question: CompetitionSetupServiceImpl extends BaseTransactionalService implements CompetitionSetupService { @Override @Transactional public ServiceResult<SetupStatusResource> markSectionComplete(Long competitionId, CompetitionSetupSection section) { SetupStatusResource setupStatus = findOrCreateSetupStatusResource(...
### Question: EmailAddressResolver { public static EmailAddress fromNotificationTarget(NotificationTarget notificationTarget) { return new EmailAddress(notificationTarget.getEmailAddress(), notificationTarget.getName()); } private EmailAddressResolver(); static EmailAddress fromNotificationSource(NotificationSource no...
### Question: CompetitionSetupServiceImpl extends BaseTransactionalService implements CompetitionSetupService { @Override @Transactional public ServiceResult<CompetitionResource> create() { Competition competition = new Competition(); competition.setSetupComplete(false); return persistNewCompetition(competition); } @O...
### Question: AssessorCountOptionServiceImpl extends BaseTransactionalService implements AssessorCountOptionService { @Override public ServiceResult<List<AssessorCountOptionResource>> findAllByCompetitionType(Long competitionTypeId) { return serviceSuccess(simpleMap(assessorCountOptionRepository.findByCompetitionTypeId...
### Question: ProfileController { @GetMapping("/id/{userId}/get-profile-skills") public RestResult<ProfileSkillsResource> getProfileSkills(@PathVariable("userId") long userId) { return profileService.getProfileSkills(userId).toGetResponse(); } @GetMapping("/id/{userId}/get-profile-skills") RestResult<ProfileSkillsReso...
### Question: ProfileController { @PutMapping("/id/{userId}/update-profile-skills") public RestResult<Void> updateProfileSkills(@PathVariable("userId") long id, @Valid @RequestBody ProfileSkillsEditResource profileSkills) { return profileService.updateProfileSkills(id, profileSkills).toPutResponse(); } @GetMapping("/i...
### Question: ProfileController { @GetMapping("/id/{userId}/get-profile-agreement") public RestResult<ProfileAgreementResource> getProfileAgreement(@PathVariable("userId") long userId) { return profileService.getProfileAgreement(userId).toGetResponse(); } @GetMapping("/id/{userId}/get-profile-skills") RestResult<Profi...
### Question: ProfileController { @PutMapping("/id/{userId}/update-profile-agreement") public RestResult<Void> updateProfileAgreement(@PathVariable("userId") long userId) { return profileService.updateProfileAgreement(userId).toPutResponse(); } @GetMapping("/id/{userId}/get-profile-skills") RestResult<ProfileSkillsRes...
### Question: ProfileController { @GetMapping("/id/{userId}/get-user-profile") public RestResult<UserProfileResource> getUserProfile(@PathVariable("userId") Long userId) { return profileService.getUserProfile(userId).toGetResponse(); } @GetMapping("/id/{userId}/get-profile-skills") RestResult<ProfileSkillsResource> ge...
### Question: ProfileController { @PutMapping("/id/{userId}/update-user-profile") public RestResult<Void> updateUserProfile(@PathVariable("userId") Long userId, @RequestBody UserProfileResource profileDetails) { return profileService.updateUserProfile(userId, profileDetails).toPutResponse(); } @GetMapping("/id/{userId...
### Question: ProfileController { @GetMapping("/id/{userId}/profile-status") public RestResult<UserProfileStatusResource> getUserProfileStatus(@PathVariable("userId") Long userId) { return profileService.getUserProfileStatus(userId).toGetResponse(); } @GetMapping("/id/{userId}/get-profile-skills") RestResult<ProfileSk...
### Question: ProfileServiceImpl extends BaseTransactionalService implements ProfileService { @Override @Transactional public ServiceResult<Void> updateProfileSkills(long userId, ProfileSkillsEditResource profileSkills) { return find(userRepository.findById(userId), notFoundError(User.class, userId)) .andOnSuccess(user...
### Question: ProfileServiceImpl extends BaseTransactionalService implements ProfileService { @Override public ServiceResult<UserProfileResource> getUserProfile(Long userId) { return find(userRepository.findById(userId), notFoundError(User.class, userId)) .andOnSuccess(user -> { UserProfileResource profileDetails = ass...
### Question: ProfileServiceImpl extends BaseTransactionalService implements ProfileService { @Override @Transactional @UserUpdate public ServiceResult<UserResource> updateUserProfile(Long userId, UserProfileResource profileDetails) { return find(userRepository.findById(userId), notFoundError(User.class, userId)) .andO...
### Question: DoiExpiryServiceImpl extends BaseTransactionalService implements DoiExpiryService { @Override @Transactional public void notifyExpiredDoi() { ZonedDateTime expiry = Profile.startOfCurrentFinancialYear(ZonedDateTime.now()).atStartOfDay(ZoneId.systemDefault()); Page<User> expired = affiliationRepository.fin...
### Question: Profile extends AuditableEntity { public void addInnovationAreas(Set<InnovationArea> innovationAreas) { innovationAreas.forEach(this::addInnovationArea); } Profile(); void signAgreement(Agreement agreement, ZonedDateTime signedDate); Long getId(); void setId(Long id); Address getAddress(); void setAddress...
### Question: Profile extends AuditableEntity { public static boolean isAffiliationsComplete(User user) { Optional<ZonedDateTime> doiLastSignedDateTime = user.getAffiliations().stream().findAny().map(AuditableEntity::getModifiedOn); return doiLastSignedDateTime.isPresent() && doiLastSignedDateTime.get() .isAfter(startO...
### Question: Profile extends AuditableEntity { public static LocalDate startOfCurrentFinancialYear(ZonedDateTime now) { if (!DOI_EXPIRE_DATE.isAfter(MonthDay.of(now.getMonth(), now.getDayOfMonth()))) { return DOI_EXPIRE_DATE.atYear(now.getYear()); } else { return DOI_EXPIRE_DATE.atYear(now.getYear()-1); } } Profile();...
### Question: RestGrantEndpoint implements GrantEndpoint { @Override public ServiceResult<Void> send(Grant grant) { List<Grant> grantAsList = singletonList(grant); Either<ResponseEntity<Void>, ResponseEntity<JsonNode>> response = adaptor.restPostWithEntity(silRestServiceUrl + path, grantAsList, JsonNode.class, Void.cla...
### Question: RestSilCrmEndpoint implements SilCrmEndpoint { @Override public ServiceResult<Void> updateContact(SilContact silContact) { return handlingErrors(() -> { final Either<ResponseEntity<SilCrmError>, ResponseEntity<Void>> response = adaptor.restPostWithEntity(silRestServiceUrl + silCrmContacts, silContact, Voi...