public static String formatIndexBuffAttributes(String separator, CFBamIndexBuff buff) { String retval = CFBamXMsgScopeMessageFormatter.formatScopeBuffAttributes(separator, buff) + CFLibXmlUtil.formatRequiredInt64(separator, "TableId", buff.getRequiredTableId()) + CFLibXmlUtil.formatOptionalInt64( separator, "DefSchemaTenantId", buff.getOptionalDefSchemaTenantId()) + CFLibXmlUtil.formatOptionalInt64( separator, "DefSchemaId", buff.getOptionalDefSchemaId()) + CFLibXmlUtil.formatRequiredXmlString(separator, "Name", buff.getRequiredName()) + CFLibXmlUtil.formatOptionalXmlString( separator, "ShortName", buff.getOptionalShortName()) + CFLibXmlUtil.formatOptionalXmlString(separator, "Label", buff.getOptionalLabel()) + CFLibXmlUtil.formatOptionalXmlString( separator, "ShortDescription", buff.getOptionalShortDescription()) + CFLibXmlUtil.formatOptionalXmlString( separator, "Description", buff.getOptionalDescription()) + CFLibXmlUtil.formatOptionalXmlString(separator, "DbName", buff.getOptionalDbName()) + CFLibXmlUtil.formatOptionalXmlString(separator, "Suffix", buff.getOptionalSuffix()) + CFLibXmlUtil.formatRequiredBoolean(separator, "IsUnique", buff.getRequiredIsUnique()) + CFLibXmlUtil.formatRequiredBoolean( separator, "IsDbMapped", buff.getRequiredIsDbMapped()) + CFLibXmlUtil.formatRequiredBoolean( separator, "DefaultVisibility", buff.getRequiredDefaultVisibility()); return (retval); }
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { CFBamXMsgSchemaMessageFormatter schemaFormatter = null; try { // Common XML Attributes String attrId = null; String attrTenantId = null; // Attribute Extraction String attrLocalName; int numAttrs; int idxAttr; final String S_ProcName = "startElement"; final String S_LocalName = "LocalName"; assert qName.equals("RqstScopeDeleteByIdIdx"); 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("TenantId")) { if (attrTenantId != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrTenantId = attrs.getValue(idxAttr); } else 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("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 ((attrId == null) || (attrId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "Id"); } // Save named attributes to context CFLibXmlCoreContext curContext = getParser().getCurContext(); // Convert string attributes to native Java types long natTenantId; natTenantId = Long.parseLong(attrTenantId); long natId; natId = Long.parseLong(attrId); // Delete the objects schemaObj.getSchemaDefTableObj().deleteSchemaDefByIdIdx(natTenantId, natId); String response = schemaFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFBamXMsgScopeMessageFormatter.formatScopeRspnDeleted() + "\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); } }
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; // Scope Attributes String attrTenantId = 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("RqstScopeCreate"); 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()"); } // Instantiate an edit buffer for the parsed information ICFBamScopeEditObj editBuff = (ICFBamScopeEditObj) schemaObj.getScopeTableObj().newInstance().beginEdit(); CFBamScopeBuff dataBuff = (CFBamScopeBuff) editBuff.getScopeBuff(); // 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("schemaLocation")) { // ignored } 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 { 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 ((attrId == null) || (attrId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "Id"); } // Save named attributes to context CFLibXmlCoreContext curContext = getParser().getCurContext(); // Convert string attributes to native Java types // and apply the converted attributes to the editBuff. long natTenantId = Long.parseLong(attrTenantId); dataBuff.setRequiredTenantId(natTenantId); 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 create editBuff.copyBuffToPKey(); // Allow for predefined ids ICFBamScopeObj created = (ICFBamScopeObj) editBuff.create(); editBuff.endEdit(); String response = schemaFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFBamXMsgScopeMessageFormatter.formatScopeRspnCreated( "\n\t\t\t", created.getScopeBuff()) + "\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); } }
public static String formatTableBuffAttributes(String separator, CFBamTableBuff buff) { String retval = CFBamXMsgScopeMessageFormatter.formatScopeBuffAttributes(separator, buff) + CFLibXmlUtil.formatRequiredInt64( separator, "SchemaDefId", buff.getRequiredSchemaDefId()) + CFLibXmlUtil.formatOptionalInt64( separator, "DefSchemaTenantId", buff.getOptionalDefSchemaTenantId()) + CFLibXmlUtil.formatOptionalInt64( separator, "DefSchemaId", buff.getOptionalDefSchemaId()) + CFLibXmlUtil.formatRequiredXmlString(separator, "Name", buff.getRequiredName()) + CFLibXmlUtil.formatOptionalXmlString(separator, "DbName", buff.getOptionalDbName()) + CFLibXmlUtil.formatOptionalXmlString( separator, "ShortName", buff.getOptionalShortName()) + CFLibXmlUtil.formatOptionalXmlString(separator, "Label", buff.getOptionalLabel()) + CFLibXmlUtil.formatOptionalXmlString( separator, "ShortDescription", buff.getOptionalShortDescription()) + CFLibXmlUtil.formatOptionalXmlString( separator, "Description", buff.getOptionalDescription()) + CFLibXmlUtil.formatOptionalInt64( separator, "PrimaryIndexTenantId", buff.getOptionalPrimaryIndexTenantId()) + CFLibXmlUtil.formatOptionalInt64( separator, "PrimaryIndexId", buff.getOptionalPrimaryIndexId()) + CFLibXmlUtil.formatRequiredXmlString( separator, "TableClassCode", buff.getRequiredTableClassCode()) + CFLibXmlUtil.formatOptionalInt64( separator, "LookupIndexTenantId", buff.getOptionalLookupIndexTenantId()) + CFLibXmlUtil.formatOptionalInt64( separator, "LookupIndexId", buff.getOptionalLookupIndexId()) + CFLibXmlUtil.formatOptionalInt64( separator, "AltIndexTenantId", buff.getOptionalAltIndexTenantId()) + CFLibXmlUtil.formatOptionalInt64( separator, "AltIndexId", buff.getOptionalAltIndexId()) + CFLibXmlUtil.formatOptionalInt64( separator, "QualifyingTenantId", buff.getOptionalQualifyingTenantId()) + CFLibXmlUtil.formatOptionalInt64( separator, "QualifyingTableId", buff.getOptionalQualifyingTableId()) + CFLibXmlUtil.formatRequiredBoolean(separator, "PolyBase", buff.getRequiredPolyBase()) + CFLibXmlUtil.formatRequiredBoolean( separator, "IsInstantiable", buff.getRequiredIsInstantiable()) + CFLibXmlUtil.formatRequiredBoolean( separator, "HasHistory", buff.getRequiredHasHistory()) + CFLibXmlUtil.formatRequiredBoolean( separator, "HasAuditColumns", buff.getRequiredHasAuditColumns()) + CFLibXmlUtil.formatRequiredInt16( separator, "LoaderBehaviourId", buff.getRequiredLoaderBehaviourId()) + CFLibXmlUtil.formatOptionalInt16( separator, "DataScopeId", buff.getOptionalDataScopeId()) + CFLibXmlUtil.formatRequiredInt16( separator, "SecurityScopeId", buff.getRequiredSecurityScopeId()) + CFLibXmlUtil.formatOptionalInt16( separator, "ViewAccessSecurityId", buff.getOptionalViewAccessSecurityId()) + CFLibXmlUtil.formatOptionalInt16( separator, "EditAccessSecurityId", buff.getOptionalEditAccessSecurityId()) + CFLibXmlUtil.formatOptionalInt16( separator, "ViewAccessFrequencyId", buff.getOptionalViewAccessFrequencyId()) + CFLibXmlUtil.formatOptionalInt16( separator, "EditAccessFrequencyId", buff.getOptionalEditAccessFrequencyId()) + CFLibXmlUtil.formatOptionalXmlString( separator, "JObjMembers", buff.getOptionalJObjMembers()) + CFLibXmlUtil.formatOptionalXmlString( separator, "JObjInterface", buff.getOptionalJObjInterface()) + CFLibXmlUtil.formatOptionalXmlString( separator, "JObjImport", buff.getOptionalJObjImport()) + CFLibXmlUtil.formatOptionalXmlString( separator, "JObjImplementation", buff.getOptionalJObjImplementation()) + CFLibXmlUtil.formatOptionalXmlString( separator, "JEditObjMembers", buff.getOptionalJEditObjMembers()) + CFLibXmlUtil.formatOptionalXmlString( separator, "JEditObjInterface", buff.getOptionalJEditObjInterface()) + CFLibXmlUtil.formatOptionalXmlString( separator, "JEditObjImport", buff.getOptionalJEditObjImport()) + CFLibXmlUtil.formatOptionalXmlString( separator, "JEditObjImplementation", buff.getOptionalJEditObjImplementation()) + CFLibXmlUtil.formatOptionalXmlString( separator, "JTableImport", buff.getOptionalJTableImport()) + CFLibXmlUtil.formatOptionalXmlString( separator, "JTableMembers", buff.getOptionalJTableMembers()) + CFLibXmlUtil.formatOptionalXmlString( separator, "JTableInterface", buff.getOptionalJTableInterface()) + CFLibXmlUtil.formatOptionalXmlString( separator, "JTableImplementation", buff.getOptionalJTableImplementation()) + CFLibXmlUtil.formatOptionalXmlString( separator, "JTableObjImport", buff.getOptionalJTableObjImport()) + CFLibXmlUtil.formatOptionalXmlString( separator, "JTableObjMembers", buff.getOptionalJTableObjMembers()) + CFLibXmlUtil.formatOptionalXmlString( separator, "JTableObjInterface", buff.getOptionalJTableObjInterface()) + CFLibXmlUtil.formatOptionalXmlString( separator, "JTableObjImplementation", buff.getOptionalJTableObjImplementation()) + CFLibXmlUtil.formatOptionalXmlString( separator, "JDb2LUWTableImport", buff.getOptionalJDb2LUWTableImport()) + CFLibXmlUtil.formatOptionalXmlString( separator, "JDb2LUWTableMembers", buff.getOptionalJDb2LUWTableMembers()) + CFLibXmlUtil.formatOptionalXmlString( separator, "JDb2LUWTableImplementation", buff.getOptionalJDb2LUWTableImplementation()) + CFLibXmlUtil.formatOptionalXmlString( separator, "JMSSqlTableImport", buff.getOptionalJMSSqlTableImport()) + CFLibXmlUtil.formatOptionalXmlString( separator, "JMSSqlTableMembers", buff.getOptionalJMSSqlTableMembers()) + CFLibXmlUtil.formatOptionalXmlString( separator, "JMSSqlTableImplementation", buff.getOptionalJMSSqlTableImplementation()) + CFLibXmlUtil.formatOptionalXmlString( separator, "JMySqlTableImport", buff.getOptionalJMySqlTableImport()) + CFLibXmlUtil.formatOptionalXmlString( separator, "JMySqlTableMembers", buff.getOptionalJMySqlTableMembers()) + CFLibXmlUtil.formatOptionalXmlString( separator, "JMySqlTableImplementation", buff.getOptionalJMySqlTableImplementation()) + CFLibXmlUtil.formatOptionalXmlString( separator, "JOracleTableImport", buff.getOptionalJOracleTableImport()) + CFLibXmlUtil.formatOptionalXmlString( separator, "JOracleTableMembers", buff.getOptionalJOracleTableMembers()) + CFLibXmlUtil.formatOptionalXmlString( separator, "JOracleTableImplementation", buff.getOptionalJOracleTableImplementation()) + CFLibXmlUtil.formatOptionalXmlString( separator, "JPgSqlTableImport", buff.getOptionalJPgSqlTableImport()) + CFLibXmlUtil.formatOptionalXmlString( separator, "JPgSqlTableMembers", buff.getOptionalJPgSqlTableMembers()) + CFLibXmlUtil.formatOptionalXmlString( separator, "JPgSqlTableImplementation", buff.getOptionalJPgSqlTableImplementation()) + CFLibXmlUtil.formatOptionalXmlString( separator, "JSybaseTableImport", buff.getOptionalJSybaseTableImport()) + CFLibXmlUtil.formatOptionalXmlString( separator, "JSybaseTableMembers", buff.getOptionalJSybaseTableMembers()) + CFLibXmlUtil.formatOptionalXmlString( separator, "JSybaseTableImplementation", buff.getOptionalJSybaseTableImplementation()) + CFLibXmlUtil.formatOptionalXmlString( separator, "JRamTableImport", buff.getOptionalJRamTableImport()) + CFLibXmlUtil.formatOptionalXmlString( separator, "JRamTableMembers", buff.getOptionalJRamTableMembers()) + CFLibXmlUtil.formatOptionalXmlString( separator, "JRamTableImplementation", buff.getOptionalJRamTableImplementation()) + CFLibXmlUtil.formatOptionalXmlString( separator, "JSaxLoaderImport", buff.getOptionalJSaxLoaderImport()) + CFLibXmlUtil.formatOptionalXmlString( separator, "JSaxLoaderStartElement", buff.getOptionalJSaxLoaderStartElement()) + CFLibXmlUtil.formatOptionalXmlString( separator, "JSaxLoaderEndElement", buff.getOptionalJSaxLoaderEndElement()) + CFLibXmlUtil.formatOptionalXmlString( separator, "JXMsgTableImport", buff.getOptionalJXMsgTableImport()) + CFLibXmlUtil.formatOptionalXmlString( separator, "JXMsgTableFormatters", buff.getOptionalJXMsgTableFormatters()) + CFLibXmlUtil.formatOptionalXmlString( separator, "JXMsgRqstTableImport", buff.getOptionalJXMsgRqstTableImport()) + CFLibXmlUtil.formatOptionalXmlString( separator, "JXMsgRspnTableImport", buff.getOptionalJXMsgRspnTableImport()) + CFLibXmlUtil.formatOptionalXmlString( separator, "JXMsgClientTableImport", buff.getOptionalJXMsgClientTableImport()) + CFLibXmlUtil.formatOptionalXmlString( separator, "JXMsgRqstTableBody", buff.getOptionalJXMsgRqstTableBody()) + CFLibXmlUtil.formatOptionalXmlString( separator, "JXMsgRspnTableBody", buff.getOptionalJXMsgRspnTableBody()) + CFLibXmlUtil.formatOptionalXmlString( separator, "JXMsgClientTableBody", buff.getOptionalJXMsgClientTableBody()) + CFLibXmlUtil.formatRequiredBoolean( separator, "DefaultVisibility", buff.getRequiredDefaultVisibility()); return (retval); }