if ((reqComponent.getId() != null) && (reqComponent.getId().indexOf(NEW_REQ_COMP_ID) >= 0)) { reqComponent.setId(null); for (ReqCompFieldInfo field : reqComponent.getReqCompFields()) { field.setId(null);
public void statementTreeViewInfoStateSetter(String courseState, Iterator<StatementTreeViewInfo> itr) { while(itr.hasNext()) { StatementTreeViewInfo statementTreeViewInfo = (StatementTreeViewInfo)itr.next(); statementTreeViewInfo.setState(courseState); List<ReqComponentInfo> reqComponents = statementTreeViewInfo.getReqComponents(); for(Iterator<ReqComponentInfo> it = reqComponents.iterator(); it.hasNext();) it.next().setState(courseState); statementTreeViewInfoStateSetter(courseState, statementTreeViewInfo.getStatements().iterator()); } } }
/** * Builds a requirement component type context map. * * @param reqComponent Requirement component * @throws DoesNotExistException Requirement component context not found in registry * @throws OperationFailedException Creating context map failed */ private Map<String, Object> buildContextMap(ReqComponentInfo reqComponent) throws DoesNotExistException, OperationFailedException { List<Context<ReqComponentInfo>> contextList = this.contextRegistry.get(reqComponent.getType()); if(contextList == null || contextList.isEmpty()) { throw new DoesNotExistException("Requirement component context not found in registry for requirement component type id: " + reqComponent.getType()); } Map<String, Object> contextMap = new HashMap<String, Object>(); for(Context<ReqComponentInfo> context : contextList) { Map<String, Object> cm = context.createContextMap(reqComponent, new org.kuali.student.r2.common.dto.ContextInfo()); // KSCM contextInfo is not passed through here contextMap.putAll(cm); } if(logger.isInfoEnabled()) { logger.info("contextMap="+contextMap); } return contextMap; }
public static ReqComponentInfo toReqComponentInfo(ReqComponent entity) { ReqComponentInfo dto = new ReqComponentInfo(); BeanUtils.copyProperties(entity, dto, new String[]{"requiredComponentType", "reqCompField", "metaInfo"}); dto.setType(entity.getRequiredComponentType().getId()); dto.setReqCompFields(toReqCompFieldInfos(entity.getReqComponentFields())); // dto.setRequiredComponentType(toReqComponentTypeInfo(entity.getRequiredComponentType())); dto.setMetaInfo(toMetaInfo(entity)); dto.setDesc(toRichTextInfo(entity.getDescr())); // if(nlUsageTypeKey != null && language != null) { // String nl = this.naturalLanguageTranslator.translateReqComponent(entity, nlUsageTypeKey, language); // dto.setNaturalLanguageTranslation(nl); // } return dto; }
public ReqComponent toReqComponentRelation(boolean isUpdate, ReqComponentInfo reqCompInfo) throws DoesNotExistException, VersionMismatchException, InvalidParameterException { ReqComponent reqComp; if (isUpdate) { reqComp = this.statementDao.fetch(ReqComponent.class, reqCompInfo.getId()); if (reqComp == null) { throw new DoesNotExistException("ReqComponent does not exist for id: " + reqCompInfo.getId()); if (!String.valueOf(reqComp.getVersionNumber()).equals(reqCompInfo.getMetaInfo().getVersionInd())) { throw new VersionMismatchException("ReqComponent to be updated is not the current version"); ReqComponentType reqCompType = this.statementDao.fetch(ReqComponentType.class, reqCompInfo.getType()); if (reqCompType == null) { throw new InvalidParameterException("ReqComponentType does not exist for id: " + reqCompInfo.getType()); for (ReqCompFieldInfo reqCompFieldInfo : reqCompInfo.getReqCompFields()) { ReqComponentField reqCompField = new ReqComponentField(); reqComp.setDescr(toRichText(StatementRichText.class, reqCompInfo.getDesc()));
reqComp.setId(null); reqComp.setState(newState); for(ReqCompFieldInfo field:reqComp.getReqCompFields()){ field.setId(null);
List<ReqComponentInfo> rcsAfterInserts = new ArrayList<ReqComponentInfo>(7); for (ReqComponentInfo reqComponentInfo : statementTreeViewInfo.getReqComponents()) { String reqComponentId = reqComponentInfo.getId(); ReqComponentInfo origReqComponentInfo = null; ReqComponentInfo rcAfterInsert = null; reqComponentInfo.setId(null); try { rcAfterInsert = createReqComponent(reqComponentInfo.getType(), reqComponentInfo); } catch (AlreadyExistsException e) {
switch(results.getOperation()){ case CREATE: ReqComponentInfo created = statementService.createReqComponent(reqComp.getType(), reqComp); reqComp.setMetaInfo(created.getMetaInfo()); break; case UPDATE: ReqComponentInfo updated = statementService.updateReqComponent(reqComp.getId(), reqComp); reqComp.setMetaInfo(updated.getMetaInfo()); break; case DELETE: statementService.deleteReqComponent(reqComp.getId()); break;
statementTreeView.setId(null); for(ReqComponentInfo reqComp:statementTreeView.getReqComponents()){ reqComp.setId(null); for(ReqCompFieldInfo field:reqComp.getReqCompFields()){ field.setId(null);
/** * Gets requirement component fields as a map. * * @param reqComponent Requirement component * @return Map of requirement component fields */ protected Map<String, String> getReqComponentFieldMap(ReqComponentInfo reqComponent) throws OperationFailedException { //validateReqComponentFields(reqComponent); List<ReqCompFieldInfo> fields = reqComponent.getReqCompFields(); Map<String, String> map = new HashMap<String, String>(); for (ReqCompFieldInfo field : fields) { String type = field.getType(); String value = field.getValue(); map.put(type, value); } return map; }
public StatementInfo toStatementInfo(final StatementTreeViewInfo statementTreeViewInfo) { StatementInfo statementInfo = null; if (statementTreeViewInfo == null) return null; statementInfo = new StatementInfo(); copyValues(statementInfo, statementTreeViewInfo); // goes through the list of reqComponents in statementTreeViewInfo and extract the reqComponent ids if (statementTreeViewInfo.getReqComponents() != null) { List<String> reqCompIds = new ArrayList<String>(7); for (ReqComponentInfo reqComponentInfo : statementTreeViewInfo.getReqComponents()) { reqCompIds.add(reqComponentInfo.getId()); } statementInfo.setReqComponentIds(reqCompIds); } statementInfo.setState(statementTreeViewInfo.getState()); // TODO goes through the list of statements in statementTreeViewInfo and extract the statement ids if (statementTreeViewInfo.getStatements() != null) { List<String> statementIds = new ArrayList<String>(7); for (StatementTreeViewInfo subStatementTreeViewInfo : statementTreeViewInfo.getStatements()) { statementIds.add(subStatementTreeViewInfo.getId()); } statementInfo.setStatementIds(statementIds); } statementInfo.setType(statementTreeViewInfo.getType()); return statementInfo; }
@Override @Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) public ReqComponentInfo updateReqComponent(final String reqComponentId, final ReqComponentInfo reqComponentInfo) throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, VersionMismatchException { //Check Missing params checkForMissingParameter(reqComponentId, "reqComponentId"); checkForMissingParameter(reqComponentInfo, "reqComponentInfo"); //Set all the values on reqComponentInfo reqComponentInfo.setId(reqComponentId); ReqComponent reqComp = null; //Update persistence entity from the reqComponentInfo reqComp = statementAssembler.toReqComponentRelation(true, reqComponentInfo); //Update the reqComponen ReqComponent updatedReqComp = statementDao.update(reqComp); //Copy back to an reqComponentInfo and return ReqComponentInfo updReqCompInfo = StatementAssembler.toReqComponentInfo(updatedReqComp); return updReqCompInfo; }
private static void findCluSetIds(StatementTreeViewInfo rule, Set<String> list) { List<StatementTreeViewInfo> statements = rule.getStatements(); List<ReqComponentInfo> reqComponentInfos = rule.getReqComponents(); if ((statements != null) && (statements.size() > 0)) { // retrieve all statements for (StatementTreeViewInfo statement : statements) { findCluSetIds(statement, list); // inside set the children of this statementTreeViewInfo } } else if ((reqComponentInfos != null) && (reqComponentInfos.size() > 0)) { // retrieve all req. component LEAFS for (ReqComponentInfo reqComponent : reqComponentInfos) { List<ReqCompFieldInfo> fieldInfos = reqComponent.getReqCompFields(); for (ReqCompFieldInfo fieldInfo : fieldInfos) { if (RulesUtil.isCluSetWidget(fieldInfo.getType())) { list.add(fieldInfo.getValue()); } } } } }
private void updateStatementTreeViewHelper(StatementTreeViewInfo statementTreeViewInfo) throws CircularReferenceException, DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, VersionMismatchException { if (statementTreeViewInfo.getStatements() != null) { for (StatementTreeViewInfo subStatement : statementTreeViewInfo.getStatements()) { updateStatementTreeViewHelper(subStatement); } } if (statementTreeViewInfo.getReqComponents() != null) { List<ReqComponentInfo> updatedReqComponentInfos = new ArrayList<ReqComponentInfo>(7); for (ReqComponentInfo reqComponentInfo : statementTreeViewInfo.getReqComponents()) { ReqComponentInfo updatedReqComponentInfo = updateReqComponent(reqComponentInfo.getId(), reqComponentInfo); updatedReqComponentInfos.add(updatedReqComponentInfo); } statementTreeViewInfo.setReqComponents(updatedReqComponentInfos); } StatementInfo updatedStatementInfo = updateStatement(statementTreeViewInfo.getId(), statementAssembler.toStatementInfo( statementTreeViewInfo)); statementAssembler.copyValues(statementTreeViewInfo, updatedStatementInfo); }
if ((reqComponent.getId() != null) && (reqComponent.getId().indexOf(NEW_REQ_COMP_ID) >= 0)) { reqComponent.setId(null); for (ReqCompFieldInfo field : reqComponent.getReqCompFields()) { field.setId(null);
for (ReqComponentInfo reqCompInfo : treeView.getReqComponents()) { boolean isUpdate = (reqCompInfo.getId() != null);
/** * This method will recursively set the state of all statements in the tree. * <p> * WARNING: you must call the statement service in order to update statements. * <p> * * @param state is the state we should set all statements in the tree to * @param statementTreeViewInfo the tree of statements * @throws Exception */ public static void updateStatementTreeViewInfoState(String state, StatementTreeViewInfo statementTreeViewInfo) { // Set the state on the statement tree itself statementTreeViewInfo.setState(state); // Get all the requirements components for this statement List<ReqComponentInfo> reqComponents = statementTreeViewInfo.getReqComponents(); // Loop over requirements and set the state for each requirement for(Iterator<ReqComponentInfo> it = reqComponents.iterator(); it.hasNext();) it.next().setState(state); // Loop over each statement and set the state for each statement (recursively calling this method) for(Iterator<StatementTreeViewInfo> itr = statementTreeViewInfo.getStatements().iterator(); itr.hasNext();) updateStatementTreeViewInfoState(state, (StatementTreeViewInfo)itr.next()); } /**
/** * This method will recursively set the state of all statements in the tree. * <p> * WARNING: you must call the statement service in order to update statements. * <p> * * @param state is the state we should set all statements in the tree to * @param statementTreeViewInfo the tree of statements * @throws Exception */ public static void updateStatementTreeViewInfoState(String state, StatementTreeViewInfo statementTreeViewInfo) { // Set the state on the statement tree itself statementTreeViewInfo.setState(state); // Get all the requirements components for this statement List<ReqComponentInfo> reqComponents = statementTreeViewInfo.getReqComponents(); // Loop over requirements and set the state for each requirement for(Iterator<ReqComponentInfo> it = reqComponents.iterator(); it.hasNext();) it.next().setState(state); // Loop over each statement and set the state for each statement (recursively calling this method) for(Iterator<StatementTreeViewInfo> itr = statementTreeViewInfo.getStatements().iterator(); itr.hasNext();) updateStatementTreeViewInfoState(state, (StatementTreeViewInfo)itr.next()); } /**
it.next().setState(state);