public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { CFBamXMsgSchemaMessageFormatter schemaFormatter = null; try { // Common XML Attributes String attrId = null; String attrRevision = null; // IndexCol Attributes String attrTenantId = null; String attrIndexId = null; String attrDefSchemaTenantId = null; String attrDefSchemaId = null; String attrName = null; String attrShortName = null; String attrLabel = null; String attrShortDescription = null; String attrDescription = null; String attrColumnId = null; String attrIsAscending = null; String attrPrevTenantId = null; String attrPrevId = null; String attrNextTenantId = null; String attrNextId = null; String attrDefaultVisibility = null; String attrCreatedAt = null; String attrCreatedBy = null; String attrUpdatedAt = null; String attrUpdatedBy = null; // Attribute Extraction String attrLocalName; int numAttrs; int idxAttr; final String S_ProcName = "startElement"; final String S_LocalName = "LocalName"; assert qName.equals("RqstIndexColUpdate"); CFBamXMsgRqstHandler xmsgRqstHandler = (CFBamXMsgRqstHandler) getParser(); if (xmsgRqstHandler == null) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "getParser()"); } schemaFormatter = xmsgRqstHandler.getSchemaMessageFormatter(); ICFBamSchemaObj schemaObj = xmsgRqstHandler.getSchemaObj(); if (schemaObj == null) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "getParser().getSchemaObj()"); } // Extract Attributes numAttrs = attrs.getLength(); for (idxAttr = 0; idxAttr < numAttrs; idxAttr++) { attrLocalName = attrs.getLocalName(idxAttr); if (attrLocalName.equals("Id")) { if (attrId != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("Revision")) { if (attrRevision != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrRevision = attrs.getValue(idxAttr); } else if (attrLocalName.equals("CreatedAt")) { if (attrCreatedAt != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrCreatedAt = attrs.getValue(idxAttr); } else if (attrLocalName.equals("CreatedBy")) { if (attrCreatedBy != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrCreatedBy = attrs.getValue(idxAttr); } else if (attrLocalName.equals("UpdatedAt")) { if (attrUpdatedAt != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrUpdatedAt = attrs.getValue(idxAttr); } else if (attrLocalName.equals("UpdatedBy")) { if (attrUpdatedBy != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrUpdatedBy = attrs.getValue(idxAttr); } else if (attrLocalName.equals("TenantId")) { if (attrTenantId != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrTenantId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("IndexId")) { if (attrIndexId != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrIndexId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("DefSchemaTenantId")) { if (attrDefSchemaTenantId != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrDefSchemaTenantId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("DefSchemaId")) { if (attrDefSchemaId != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrDefSchemaId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("Name")) { if (attrName != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrName = attrs.getValue(idxAttr); } else if (attrLocalName.equals("ShortName")) { if (attrShortName != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrShortName = attrs.getValue(idxAttr); } else if (attrLocalName.equals("Label")) { if (attrLabel != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrLabel = attrs.getValue(idxAttr); } else if (attrLocalName.equals("ShortDescription")) { if (attrShortDescription != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrShortDescription = attrs.getValue(idxAttr); } else if (attrLocalName.equals("Description")) { if (attrDescription != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrDescription = attrs.getValue(idxAttr); } else if (attrLocalName.equals("ColumnId")) { if (attrColumnId != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrColumnId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("IsAscending")) { if (attrIsAscending != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrIsAscending = attrs.getValue(idxAttr); } else if (attrLocalName.equals("PrevTenantId")) { if (attrPrevTenantId != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrPrevTenantId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("PrevId")) { if (attrPrevId != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrPrevId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("NextTenantId")) { if (attrNextTenantId != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrNextTenantId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("NextId")) { if (attrNextId != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrNextId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("DefaultVisibility")) { if (attrDefaultVisibility != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrDefaultVisibility = attrs.getValue(idxAttr); } else if (attrLocalName.equals("schemaLocation")) { // ignored } else { throw CFLib.getDefaultExceptionFactory() .newUnrecognizedAttributeException( getClass(), S_ProcName, getParser().getLocationInfo(), attrLocalName); } } // Ensure that required attributes have values if ((attrTenantId == null) || (attrTenantId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "TenantId"); } if ((attrIndexId == null) || (attrIndexId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "IndexId"); } if ((attrId == null) || (attrId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "Id"); } if (attrName == null) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "Name"); } if ((attrColumnId == null) || (attrColumnId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "ColumnId"); } if ((attrIsAscending == null) || (attrIsAscending.length() <= 0)) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "IsAscending"); } if ((attrDefaultVisibility == null) || (attrDefaultVisibility.length() <= 0)) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "DefaultVisibility"); } if ((attrRevision == null) || (attrRevision.length() <= 0)) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "Revision"); } if ((attrCreatedAt == null) || (attrCreatedAt.length() <= 0)) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "CreatedAt"); } if ((attrCreatedBy == null) || (attrCreatedBy.length() <= 0)) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "CreatedBy"); } if ((attrUpdatedAt == null) || (attrUpdatedAt.length() <= 0)) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "UpdatedAt"); } if ((attrUpdatedBy == null) || (attrUpdatedBy.length() <= 0)) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "UpdatedBy"); } // Save named attributes to context CFLibXmlCoreContext curContext = getParser().getCurContext(); // Instantiate a PKey buffer for the parsed information CFBamIndexColPKey pkey = ((ICFBamSchema) schemaObj.getBackingStore()).getFactoryIndexCol().newPKey(); long natTenantId; natTenantId = Long.parseLong(attrTenantId); pkey.setRequiredTenantId(natTenantId); long natId; natId = Long.parseLong(attrId); pkey.setRequiredId(natId); // Read the instance ICFBamIndexColObj origBuff = ((ICFBamIndexColObj) schemaObj.getIndexColTableObj().readIndexCol(pkey)); if (origBuff == null) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException( getClass(), S_ProcName, 0, "getIndexColTableObj().readIndexCol()"); } else { // Edit the instance ICFBamIndexColEditObj editBuff = (ICFBamIndexColEditObj) origBuff.beginEdit(); CFBamIndexColBuff dataBuff = editBuff.getIndexColBuff(); // Convert string attributes to native Java types // and apply the converted attributes to the editBuff. long natIndexId = Long.parseLong(attrIndexId); dataBuff.setRequiredIndexId(natIndexId); Long natDefSchemaTenantId; if ((attrDefSchemaTenantId == null) || (attrDefSchemaTenantId.length() <= 0)) { natDefSchemaTenantId = null; } else { natDefSchemaTenantId = new Long(Long.parseLong(attrDefSchemaTenantId)); } dataBuff.setOptionalDefSchemaTenantId(natDefSchemaTenantId); Long natDefSchemaId; if ((attrDefSchemaId == null) || (attrDefSchemaId.length() <= 0)) { natDefSchemaId = null; } else { natDefSchemaId = new Long(Long.parseLong(attrDefSchemaId)); } dataBuff.setOptionalDefSchemaId(natDefSchemaId); String natName = attrName; dataBuff.setRequiredName(natName); String natShortName = attrShortName; dataBuff.setOptionalShortName(natShortName); String natLabel = attrLabel; dataBuff.setOptionalLabel(natLabel); String natShortDescription = attrShortDescription; dataBuff.setOptionalShortDescription(natShortDescription); String natDescription = attrDescription; dataBuff.setOptionalDescription(natDescription); long natColumnId = Long.parseLong(attrColumnId); dataBuff.setRequiredColumnId(natColumnId); boolean natIsAscending; if (attrIsAscending.equals("true") || attrIsAscending.equals("yes") || attrIsAscending.equals("1")) { natIsAscending = true; } else if (attrIsAscending.equals("false") || attrIsAscending.equals("no") || attrIsAscending.equals("0")) { natIsAscending = false; } else { throw CFLib.getDefaultExceptionFactory() .newUsageException( getClass(), S_ProcName, "Unexpected IsAscending value, must be one of true, false, yes, no, 1, or 0, not \"" + attrIsAscending + "\""); } dataBuff.setRequiredIsAscending(natIsAscending); Long natPrevTenantId; if ((attrPrevTenantId == null) || (attrPrevTenantId.length() <= 0)) { natPrevTenantId = null; } else { natPrevTenantId = new Long(Long.parseLong(attrPrevTenantId)); } dataBuff.setOptionalPrevTenantId(natPrevTenantId); Long natPrevId; if ((attrPrevId == null) || (attrPrevId.length() <= 0)) { natPrevId = null; } else { natPrevId = new Long(Long.parseLong(attrPrevId)); } dataBuff.setOptionalPrevId(natPrevId); Long natNextTenantId; if ((attrNextTenantId == null) || (attrNextTenantId.length() <= 0)) { natNextTenantId = null; } else { natNextTenantId = new Long(Long.parseLong(attrNextTenantId)); } dataBuff.setOptionalNextTenantId(natNextTenantId); Long natNextId; if ((attrNextId == null) || (attrNextId.length() <= 0)) { natNextId = null; } else { natNextId = new Long(Long.parseLong(attrNextId)); } dataBuff.setOptionalNextId(natNextId); boolean natDefaultVisibility; if (attrDefaultVisibility.equals("true") || attrDefaultVisibility.equals("yes") || attrDefaultVisibility.equals("1")) { natDefaultVisibility = true; } else if (attrDefaultVisibility.equals("false") || attrDefaultVisibility.equals("no") || attrDefaultVisibility.equals("0")) { natDefaultVisibility = false; } else { throw CFLib.getDefaultExceptionFactory() .newUsageException( getClass(), S_ProcName, "Unexpected DefaultVisibility value, must be one of true, false, yes, no, 1, or 0, not \"" + attrDefaultVisibility + "\""); } dataBuff.setRequiredDefaultVisibility(natDefaultVisibility); int natRevision = Integer.parseInt(attrRevision); dataBuff.setRequiredRevision(natRevision); UUID createdBy = null; if (attrCreatedBy != null) { createdBy = UUID.fromString(attrCreatedBy); } Calendar createdAt = null; if (attrCreatedAt != null) { createdAt = CFLibXmlUtil.parseTimestamp(attrCreatedAt); } UUID updatedBy = null; if (attrUpdatedBy != null) { updatedBy = UUID.fromString(attrUpdatedBy); } Calendar updatedAt = null; if (attrUpdatedAt != null) { updatedAt = CFLibXmlUtil.parseTimestamp(attrUpdatedAt); } if (createdBy != null) { dataBuff.setCreatedByUserId(createdBy); } if (createdAt != null) { dataBuff.setCreatedAt(createdAt); } if (updatedBy != null) { dataBuff.setUpdatedByUserId(updatedBy); } if (updatedAt != null) { dataBuff.setUpdatedAt(updatedAt); } // Attempt the update editBuff.update(); editBuff.endEdit(); String response = schemaFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFBamXMsgIndexColMessageFormatter.formatIndexColRspnUpdated( "\n\t\t\t", origBuff.getIndexColBuff()) + "\n" + schemaFormatter.formatRspnXmlPostamble(); ((CFBamXMsgRqstHandler) getParser()).appendResponse(response); } } catch (RuntimeException e) { CFBamXMsgRqstHandler xmsgRqstHandler = ((CFBamXMsgRqstHandler) getParser()); schemaFormatter = xmsgRqstHandler.getSchemaMessageFormatter(); String response = schemaFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFBamXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n" + schemaFormatter.formatRspnXmlPostamble(); xmsgRqstHandler.resetResponse(); xmsgRqstHandler.appendResponse(response); xmsgRqstHandler.setCaughtException(true); } catch (Error e) { CFBamXMsgRqstHandler xmsgRqstHandler = ((CFBamXMsgRqstHandler) getParser()); schemaFormatter = xmsgRqstHandler.getSchemaMessageFormatter(); String response = schemaFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFBamXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n" + schemaFormatter.formatRspnXmlPostamble(); xmsgRqstHandler.resetResponse(); xmsgRqstHandler.appendResponse(response); xmsgRqstHandler.setCaughtException(true); } }
/** * The core evaluation of ColumnInOwnerRelation is also to determine if an index definition is in * an owner relation. * * <p>WORKING: Yes, I know. This should be a business method instead of copying the code in * ICFBamIndexObj and MSIsaGenBindColumnInOwnerRelation. * * @param genDef to be considered * @return True if the column participates in an owner relation. */ public Boolean isColumnInOwnerRelation() { ICFLibAnyObj focusDef; ICFBamTableObj tableDef; final String S_ProcName = "isColumnInOwnerRelation() "; if (this instanceof ICFBamAtomObj) { ICFBamAtomObj atomDef = (ICFBamAtomObj) this; ICFLibAnyObj atomScopeDef = atomDef.getObjScope(); tableDef = (ICFBamTableObj) atomScopeDef; focusDef = this; } else if (this instanceof ICFBamTableColObj) { ICFBamTableColObj tableColDef = (ICFBamTableColObj) this; ICFLibAnyObj tableColScopeDef = tableColDef.getObjScope(); tableDef = (ICFBamTableObj) tableColScopeDef; focusDef = this; } else if (this instanceof ICFBamIndexColObj) { ICFBamIndexColObj indexColDef = (ICFBamIndexColObj) this; focusDef = indexColDef.getRequiredLookupColumn(); if (focusDef instanceof ICFBamAtomObj) { tableDef = (ICFBamTableObj) ((ICFBamAtomObj) focusDef).getObjScope(); } else if (focusDef instanceof ICFBamTableColObj) { tableDef = (ICFBamTableObj) ((ICFBamTableColObj) focusDef).getObjScope(); } else { throw new RuntimeException( S_ProcName + "genContext.getGenDef().getColumnDef() for a ICFBamIndexColObj did not return a ICFBamAtomObj" + " nor a ICFBamTableColObj"); } } else if (this instanceof ICFBamRelationColObj) { ICFBamRelationColObj relColDef = (ICFBamRelationColObj) this; ICFLibAnyObj columnDef = relColDef.getRequiredLookupFromCol(); if (columnDef instanceof ICFBamAtomObj) { focusDef = columnDef; tableDef = (ICFBamTableObj) columnDef.getObjScope(); } else if (columnDef instanceof ICFBamTableColObj) { focusDef = columnDef; tableDef = (ICFBamTableObj) columnDef.getObjScope(); } else { throw new RuntimeException( S_ProcName + "genContext.getGenDef().getFromColumnDef() for a ICFBamIndexColObj did not return a ICFBamAtomObj" + " nor a ICFBamTableColObj"); } } else { throw new RuntimeException( S_ProcName + "genContext.getGenDef() did not return a ICFBamAtomObj, ICFBamTableColObj, nor ICFBamIndexColObj instance"); } List<ICFBamRelationObj> ownerRelations = tableDef.getContainerOwnerRelations(); if ((ownerRelations == null) || ((ownerRelations != null) && (ownerRelations.size() == 0))) { return (false); } ListIterator<ICFBamRelationObj> ownerEnumerator = ownerRelations.listIterator(); ICFBamRelationObj ownerRelation; ICFBamRelationColObj ownerRelationCol; Iterator<ICFBamRelationColObj> ownerRelationCols; while (ownerEnumerator.hasNext()) { ownerRelation = ownerEnumerator.next(); ownerRelationCols = ownerRelation.getOptionalComponentsColumns().iterator(); while (ownerRelationCols.hasNext()) { ownerRelationCol = ownerRelationCols.next(); if (ownerRelationCol.getRequiredLookupFromCol() == focusDef) { return (true); } } } return (false); }