private int check_canSystemContainerBeCreated() { // this is the actual container section type String containerSectionType = m_parentAction.action_section_type(); // this is the current section where the cursor is, we want to compare actual container // section type with required. String currentSection = ooDocument.currentSectionName(); HashMap<String, String> metaMap = ooDocument.getSectionMetadataAttributes(currentSection); if (metaMap.containsKey("BungeniSectionType")) { String currentSectionType = metaMap.get("BungeniSectionType"); if (currentSectionType.equals(containerSectionType)) { return BungeniError.VALID_CONTAINER_FOR_SYSTEM_ACTION; } else { return BungeniError.INVALID_CONTAINER_FOR_SYSTEM_ACTION; } } else return BungeniError.INVALID_CONTAINER_FOR_SYSTEM_ACTION; }
private int check_containment_Section(String currentContainerSection) { int error = BungeniError.GENERAL_ERROR; try { // get valid parent actions String strActionName = m_parentAction.action_name(); dbSettings.Connect(); String fetchParentQuery = SettingsQueryFactory.Q_FETCH_PARENT_ACTIONS(strActionName); log.debug("checkContainmentSection = " + fetchParentQuery); QueryResults qr = dbSettings.QueryResults(fetchParentQuery); dbSettings.EndConnect(); String[] actionSectionTypes = qr.getSingleColumnResult("ACTION_SECTION_TYPE"); // there can be multiple parents... so we iterate through the array if one of them is a valid // parent HashMap<String, String> sectionMetadata = ooDocument.getSectionMetadataAttributes(currentContainerSection); // if (sectionMetadata.get) String strDocSectionType = ""; if (sectionMetadata.containsKey("BungeniSectionType")) { strDocSectionType = sectionMetadata.get("BungeniSectionType").trim(); // check the doc section type against the array of valid action section types for (String sectionType : actionSectionTypes) { if (strDocSectionType.equals(sectionType.trim())) { error = BungeniError.VALID_SECTION_CONTAINER; break; } else { error = BungeniError.INVALID_SECTION_CONTAINER; } } } else { error = BungeniError.INVALID_SECTION_CONTAINER; } } catch (Exception ex) { log.error("check_containmentSection : " + ex.getMessage()); log.error("check_containmentSection : " + CommonExceptionUtils.getStackTrace(ex)); } finally { return error; } }