@Override public VersionDisplayInfo getLatestVersion(String versionIndId, String objectTypeURI) { Query query = em.createNamedQuery("Clu.findLatestVersion"); query.setParameter("versionIndId", versionIndId); VersionDisplayInfo versionDisplayInfo = (VersionDisplayInfo)query.getSingleResult(); versionDisplayInfo.setRefObjectUri(objectTypeURI); return versionDisplayInfo; }
public static VersionInfo toVersionInfo(Version version) { if (version == null) { return null; } VersionInfo versionInfo = new VersionInfo(); versionInfo.setCurrentVersionStart(version.getCurrentVersionStart()); versionInfo.setCurrentVersionEnd(version.getCurrentVersionEnd()); versionInfo.setSequenceNumber(version.getSequenceNumber()); versionInfo.setVersionComment(version.getVersionComment()); versionInfo.setVersionIndId(version.getVersionIndId()); versionInfo.setVersionedFromId(version.getVersionedFromId()); return versionInfo; } }
/** * Get the current version of course from another version of course * * */ protected CourseInfo getCurrentVersionOfCourse(CourseInfo course,ContextInfo contextInfo) throws Exception { // Get version independent id of course String verIndId = course.getVersion().getVersionIndId(); // Get id of current version of course given the versionindependen id VersionDisplayInfo curVerDisplayInfo = courseService.getCurrentVersion( CourseServiceConstants.COURSE_NAMESPACE_URI, verIndId,contextInfo); String curVerId = curVerDisplayInfo.getId(); // Return the current version of the course CourseInfo currVerCourse = courseService.getCourse(curVerId,contextInfo); return currVerCourse; }
/** * This method will make this version of the major discipline the current one. * * @param majorDisciplineInfo * @param contextInfo */ private void makeCurrent(MajorDisciplineInfo majorDisciplineInfo, ContextInfo contextInfo) throws Exception { // Check if this is the current version before trying to make it current // (the web service will error if you try to make a version current that is already current) VersionDisplayInfo currentVersion = null; currentVersion = programService.getCurrentVersion(ProgramServiceConstants.PROGRAM_NAMESPACE_MAJOR_DISCIPLINE_URI, majorDisciplineInfo.getVersion().getVersionIndId(), contextInfo); // If this is not the current version, then make it current if (!currentVersion.getSequenceNumber().equals(majorDisciplineInfo.getVersion().getSequenceNumber())) { programService.setCurrentMajorDisciplineVersion(majorDisciplineInfo.getId(), null, contextInfo); } }
List<VersionDisplayInfo> versions = programService.getVersions(ProgramServiceConstants.PROGRAM_NAMESPACE_MAJOR_DISCIPLINE_URI, majorDisciplineInfo.getVersion().getVersionIndId(),ContextUtils.getContextInfo()); sequenceNumber = majorDisciplineInfo.getVersion().getSequenceNumber(); if (versionInfo.getSequenceNumber().equals(sequenceNumber)) { previousVersion = programService.getMajorDiscipline(versionInfo.getId(),ContextUtils.getContextInfo()); break;
/** * Gets a CLU. * * @param cluId CLU id * @return CLU * @throws OperationFailedException If retrieving CLU fails */ public CluInfo getCluInfo(String cluId, ContextInfo contextInfo) throws OperationFailedException { if (cluId == null) { return null; } try { VersionDisplayInfo versionInfo = cluService.getCurrentVersion(CluServiceConstants.CLU_NAMESPACE_URI, cluId, null); CluInfo clu = this.cluService.getClu(versionInfo.getId(), contextInfo); return clu; } catch(Exception e) { throw new OperationFailedException(e.getMessage(), e); } }
@Override protected Object save(Object dto, Map<String, Object> properties,ContextInfo contextInfo) throws Exception { if (dto instanceof CoreProgramInfo) { CoreProgramInfo cpInfo = (CoreProgramInfo) dto; if (cpInfo.getId() == null && cpInfo.getVersion() != null) { String coreVersionIndId = cpInfo.getVersion().getVersionIndId(); cpInfo = programService.createNewCoreProgramVersion(coreVersionIndId, "New core program version", contextInfo); } else if (cpInfo.getId() == null) { cpInfo = programService.createCoreProgram(cpInfo.getTypeKey(), cpInfo,contextInfo); } else { cpInfo = programService.updateCoreProgram(cpInfo.getId(), cpInfo.getTypeKey(), cpInfo, contextInfo); } return cpInfo; } else { throw new InvalidParameterException("Only persistence of CoreProgram is supported by this DataService implementation."); } }
/** * This method will make this version of the major discipline the current one. * * @param majorDisciplineInfo */ private void makeCurrent(MajorDisciplineInfo majorDisciplineInfo) throws Exception { // Check if this is the current version before trying to make it current // (the web service will error if you try to make a version current that is already current) VersionDisplayInfo currentVersion = programService.getCurrentVersion(ProgramServiceConstants.PROGRAM_NAMESPACE_MAJOR_DISCIPLINE_URI, majorDisciplineInfo.getVersion().getVersionIndId(),ContextUtils.getContextInfo()); // If this is not the current version, then make it current if (!currentVersion.getSequenceNumber().equals(majorDisciplineInfo.getVersion().getSequenceNumber())) { programService.setCurrentMajorDisciplineVersion(majorDisciplineInfo.getId(), null,ContextUtils.getContextInfo()); } }
/** * Get the current version of program given the selected version of program * * @param majorDisciplineInfo * @param contextInfo */ protected MajorDisciplineInfo getCurrentVersion(MajorDisciplineInfo majorDisciplineInfo, ContextInfo contextInfo) throws Exception { // Get version independent id of program String verIndId = majorDisciplineInfo.getVersion().getVersionIndId(); // Get id of current version of program given the version independent id VersionDisplayInfo curVerDisplayInfo = null; curVerDisplayInfo = programService.getCurrentVersion(ProgramServiceConstants.PROGRAM_NAMESPACE_MAJOR_DISCIPLINE_URI, verIndId, contextInfo); String curVerId = null; curVerId = curVerDisplayInfo.getId(); // Return the current version of the course MajorDisciplineInfo currentVersion = programService.getMajorDiscipline(curVerId, contextInfo); return currentVersion; }
@Override public VersionDisplayInfo getVersionBySequenceNumber(String versionIndId, String objectTypeURI, Long sequenceNumber) { Query query = em.createNamedQuery("Clu.findVersionBySequence"); query.setParameter("versionIndId", versionIndId); query.setParameter("sequenceNumber", sequenceNumber); VersionDisplayInfo versionDisplayInfo = (VersionDisplayInfo)query.getSingleResult(); versionDisplayInfo.setRefObjectUri(objectTypeURI); return versionDisplayInfo; }
/** * This method will make this version of the major discipline the current one. * * @param coreProgramInfo */ private void makeCurrent(CoreProgramInfo coreProgramInfo) throws Exception { // Check if this is the current version before trying to make it current // (the web service will error if you try to make a version current that is already current) VersionDisplayInfo currentVersion = programService.getCurrentVersion(ProgramServiceConstants.PROGRAM_NAMESPACE_MAJOR_DISCIPLINE_URI, coreProgramInfo.getVersion().getVersionIndId(),ContextUtils.getContextInfo()); // If this is not the current version, then make it current if ( !currentVersion.getSequenceNumber().equals(coreProgramInfo.getVersion().getSequenceNumber())) { programService.setCurrentCoreProgramVersion(coreProgramInfo.getId(), null,ContextUtils.getContextInfo()); } }
/** * Get the current version of program given the selected version of program * * @param credentialProgramInfo */ protected CredentialProgramInfo getCurrentVersion(CredentialProgramInfo credentialProgramInfo) throws Exception { // Get version independent id of program String verIndId = credentialProgramInfo.getVersion().getVersionIndId(); // Get id of current version of program given the version independent id VersionDisplayInfo curVerDisplayInfo = programService.getCurrentVersion( ProgramServiceConstants.PROGRAM_NAMESPACE_MAJOR_DISCIPLINE_URI, verIndId,ContextUtils.getContextInfo()); String curVerId = curVerDisplayInfo.getId(); // Return the current version of the course CredentialProgramInfo currentVersion = programService.getCredentialProgram(curVerId,ContextUtils.getContextInfo()); return currentVersion; }
@Override public VersionDisplayInfo getFirstVersion(String versionIndId, String objectTypeURI) { Query query = em.createNamedQuery("Clu.findFirstVersion"); query.setParameter("versionIndId", versionIndId); VersionDisplayInfo versionDisplayInfo = (VersionDisplayInfo)query.getSingleResult(); versionDisplayInfo.setRefObjectUri(objectTypeURI); return versionDisplayInfo; }
/** * This method will make this version of the major discipline the current one. * * @param credentialProgramInfo */ private void makeCurrent(CredentialProgramInfo credentialProgramInfo) throws Exception { // Check if this is the current version before trying to make it current // (the web service will error if you try to make a version current that is already current) VersionDisplayInfo currentVersion = programService.getCurrentVersion(ProgramServiceConstants.PROGRAM_NAMESPACE_MAJOR_DISCIPLINE_URI, credentialProgramInfo.getVersion().getVersionIndId(),ContextUtils.getContextInfo()); // If this is not the current version, then make it current if (!currentVersion.getSequenceNumber().equals(credentialProgramInfo.getVersion().getSequenceNumber())) { programService.setCurrentCredentialProgramVersion(credentialProgramInfo.getId(), null,ContextUtils.getContextInfo()); } }
/** * Get the current version of program given the selected version of program * * @param verIndId */ protected CoreProgramInfo getCurrentVersion(CoreProgramInfo coreProgramInfo) throws Exception { // Get version independent id of program String verIndId = coreProgramInfo.getVersion().getVersionIndId(); // Get id of current version of program given the version independent id VersionDisplayInfo curVerDisplayInfo = programService.getCurrentVersion(ProgramServiceConstants.PROGRAM_NAMESPACE_MAJOR_DISCIPLINE_URI, verIndId,ContextUtils.getContextInfo()); String curVerId = curVerDisplayInfo.getId(); // Return the current version of the course CoreProgramInfo currentVersion = programService.getCoreProgram(curVerId,ContextUtils.getContextInfo()); return currentVersion; }
@Override public VersionDisplayInfo getCurrentVersionOnDate(String versionIndId, String objectTypeURI, Date date) { Query query = em.createNamedQuery("Clu.findCurrentVersionOnDate"); query.setParameter("versionIndId", versionIndId); query.setParameter("date", date); VersionDisplayInfo versionDisplayInfo = (VersionDisplayInfo)query.getSingleResult(); versionDisplayInfo.setRefObjectUri(objectTypeURI); return versionDisplayInfo; }
/** * This method will make this version of the major discipline the current one. * * @param majorDisciplineInfo */ private void makeCurrent(MajorDisciplineInfo majorDisciplineInfo) throws Exception { // Check if this is the current version before trying to make it current // (the web service will error if you try to make a version current that is already current) VersionDisplayInfo currentVersion = null; currentVersion = programService.getCurrentVersion(ProgramServiceConstants.PROGRAM_NAMESPACE_MAJOR_DISCIPLINE_URI, majorDisciplineInfo.getVersion().getVersionIndId(),ContextUtils.getContextInfo()); // If this is not the current version, then make it current if (!currentVersion.getSequenceNumber().equals(majorDisciplineInfo.getVersion().getSequenceNumber())) { programService.setCurrentMajorDisciplineVersion(majorDisciplineInfo.getId(), null,ContextUtils.getContextInfo()); } }
/** * Get the current version of program given the selected version of program * * @param verIndId */ protected MajorDisciplineInfo getCurrentVersion(MajorDisciplineInfo majorDisciplineInfo) throws Exception { // Get version independent id of program String verIndId = majorDisciplineInfo.getVersion().getVersionIndId(); // Get id of current version of program given the version independent id VersionDisplayInfo curVerDisplayInfo = null; curVerDisplayInfo = programService.getCurrentVersion(ProgramServiceConstants.PROGRAM_NAMESPACE_MAJOR_DISCIPLINE_URI, verIndId,ContextUtils.getContextInfo()); String curVerId = curVerDisplayInfo.getId(); // Return the current version of the course MajorDisciplineInfo currentVersion = programService.getMajorDiscipline(curVerId,ContextUtils.getContextInfo()); return currentVersion; }
@Override public VersionDisplayInfo getCurrentCluVersionInfo(String cluVersionIndId, String objectTypeURI) { Query query = em.createNamedQuery("Clu.findCurrentVersionInfo"); query.setParameter("versionIndId", cluVersionIndId); query.setParameter("currentTime", new Date()); VersionDisplayInfo versionDisplayInfo = (VersionDisplayInfo)query.getSingleResult(); versionDisplayInfo.setRefObjectUri(objectTypeURI); return versionDisplayInfo; }
@Override public List<VersionDisplayInfo> getVersions(String versionIndId, String objectTypeURI) { Query query = em.createNamedQuery("Clu.findVersions"); query.setParameter("versionIndId", versionIndId); List<VersionDisplayInfo> versionDisplayInfos = (List<VersionDisplayInfo>)query.getResultList(); if(versionDisplayInfos==null){ versionDisplayInfos = Collections.emptyList(); } for(VersionDisplayInfo versionDisplayInfo:versionDisplayInfos){ versionDisplayInfo.setRefObjectUri(objectTypeURI); } return versionDisplayInfos; }