public void deleteUuidDefByIdIdx(CFSecurityAuthorization Authorization, CFBamValuePKey argKey) { final String S_ProcName = "deleteUuidDefByIdIdx"; CFBamUuidDefBuff cur; LinkedList<CFBamUuidDefBuff> matchSet = new LinkedList<CFBamUuidDefBuff>(); Iterator<CFBamUuidDefBuff> values = dictByPKey.values().iterator(); while (values.hasNext()) { cur = values.next(); if (argKey.equals(cur)) { matchSet.add(cur); } } Iterator<CFBamUuidDefBuff> iterMatch = matchSet.iterator(); while (iterMatch.hasNext()) { cur = iterMatch.next(); String subClassCode = cur.getClassCode(); if ("UIDD".equals(subClassCode)) { schema.getTableUuidDef().deleteUuidDef(Authorization, cur); } else if ("UIDC".equals(subClassCode)) { schema.getTableUuidCol().deleteUuidCol(Authorization, (CFBamUuidColBuff) cur); } else if ("UIDT".equals(subClassCode)) { schema.getTableUuidType().deleteUuidType(Authorization, (CFBamUuidTypeBuff) cur); } else if ("IGUU".equals(subClassCode)) { schema.getTableUuidGen().deleteUuidGen(Authorization, (CFBamUuidGenBuff) cur); } else { throw CFLib.getDefaultExceptionFactory() .newUnsupportedClassException( getClass(), S_ProcName, "subClassCode", cur, "Instance of or subclass of UuidDef must not be \"" + subClassCode + "\""); } } }
public CFBamUuidDefBuff readDerived(CFSecurityAuthorization Authorization, CFBamValuePKey PKey) { final String S_ProcName = "CFBamRamUuidDef.readDerived"; CFBamValuePKey key = schema.getFactoryValue().newPKey(); key.setRequiredTenantId(PKey.getRequiredTenantId()); key.setRequiredId(PKey.getRequiredId()); CFBamUuidDefBuff buff; if (dictByPKey.containsKey(key)) { buff = dictByPKey.get(key); } else { buff = null; } return (buff); }
public void deleteUuidDefByIdIdx( CFSecurityAuthorization Authorization, long argTenantId, long argId) { CFBamValuePKey key = schema.getFactoryValue().newPKey(); key.setRequiredTenantId(argTenantId); key.setRequiredId(argId); deleteUuidDefByIdIdx(Authorization, key); }
public void createUuidDef(CFSecurityAuthorization Authorization, CFBamUuidDefBuff Buff) { final String S_ProcName = "createUuidDef"; schema.getTableAtom().createAtom(Authorization, Buff); CFBamValuePKey pkey = schema.getFactoryValue().newPKey(); pkey.setClassCode(Buff.getClassCode()); pkey.setRequiredTenantId(Buff.getRequiredTenantId()); pkey.setRequiredId(Buff.getRequiredId()); // Validate unique indexes if (dictByPKey.containsKey(pkey)) { throw CFLib.getDefaultExceptionFactory() .newPrimaryKeyNotNewException(getClass(), S_ProcName, pkey); } // Validate foreign keys { boolean allNull = true; allNull = false; allNull = false; if (!allNull) { if (null == schema .getTableAtom() .readDerivedByIdIdx( Authorization, Buff.getRequiredTenantId(), Buff.getRequiredId())) { throw CFLib.getDefaultExceptionFactory() .newUnresolvedRelationException( getClass(), S_ProcName, "Superclass", "SuperClass", "Atom", null); } } } // Proceed with adding the new record dictByPKey.put(pkey, Buff); }
public void deleteUuidDef(CFSecurityAuthorization Authorization, CFBamUuidDefBuff Buff) { final String S_ProcName = "CFBamRamUuidDefTable.deleteUuidDef() "; CFBamValuePKey pkey = schema.getFactoryValue().newPKey(); pkey.setRequiredTenantId(Buff.getRequiredTenantId()); pkey.setRequiredId(Buff.getRequiredId()); CFBamUuidDefBuff existing = dictByPKey.get(pkey); if (existing == null) { return; } if (existing.getRequiredRevision() != Buff.getRequiredRevision()) { throw CFLib.getDefaultExceptionFactory() .newCollisionDetectedException(getClass(), "deleteUuidDef", pkey); } // Validate reverse foreign keys if (schema .getTableUuidCol() .readDerivedByIdIdx( Authorization, existing.getRequiredTenantId(), existing.getRequiredId()) != null) { throw CFLib.getDefaultExceptionFactory() .newDependentsDetectedException( getClass(), "deleteUuidDef", "Superclass", "SuperClass", "UuidCol", pkey); } if (schema .getTableUuidType() .readDerivedByIdIdx( Authorization, existing.getRequiredTenantId(), existing.getRequiredId()) != null) { throw CFLib.getDefaultExceptionFactory() .newDependentsDetectedException( getClass(), "deleteUuidDef", "Superclass", "SuperClass", "UuidType", pkey); } // Delete is valid Map<CFBamValuePKey, CFBamUuidDefBuff> subdict; dictByPKey.remove(pkey); schema.getTableAtom().deleteAtom(Authorization, Buff); }
public void updateUuidDef(CFSecurityAuthorization Authorization, CFBamUuidDefBuff Buff) { schema.getTableAtom().updateAtom(Authorization, Buff); CFBamValuePKey pkey = schema.getFactoryValue().newPKey(); pkey.setRequiredTenantId(Buff.getRequiredTenantId()); pkey.setRequiredId(Buff.getRequiredId()); CFBamUuidDefBuff existing = dictByPKey.get(pkey); if (existing == null) { throw CFLib.getDefaultExceptionFactory() .newStaleCacheDetectedException( getClass(), "updateUuidDef", "Existing record not found", "UuidDef", pkey); } // Check unique indexes // Validate foreign keys { boolean allNull = true; if (allNull) { if (null == schema .getTableAtom() .readDerivedByIdIdx( Authorization, Buff.getRequiredTenantId(), Buff.getRequiredId())) { throw CFLib.getDefaultExceptionFactory() .newUnresolvedRelationException( getClass(), "updateUuidDef", "Superclass", "SuperClass", "Atom", null); } } } // Update is valid Map<CFBamValuePKey, CFBamUuidDefBuff> subdict; dictByPKey.remove(pkey); dictByPKey.put(pkey, Buff); }
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { CFBamXMsgSchemaMessageFormatter schemaFormatter = null; try { // Common XML Attributes String attrId = null; // Primary Key Attributes for Constant Enum support String attrTenantId = null; // Attribute Extraction String attrLocalName; int numAttrs; int idxAttr; final String S_ProcName = "startElement"; final String S_LocalName = "LocalName"; assert qName.equals("RqstUInt64ColRead"); 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 a PKey buffer for the parsed information CFBamValuePKey pkey = ((ICFBamSchema) schemaObj.getBackingStore()).getFactoryValue().newPKey(); // 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("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"); } // Get current context CFLibXmlCoreContext curContext = getParser().getCurContext(); // Convert string attributes to native Java types // and apply the converted attributes to the editBuff. long natTenantId; natTenantId = Long.parseLong(attrTenantId); pkey.setRequiredTenantId(natTenantId); pkey.setRequiredTenantId(natTenantId); long natId; natId = Long.parseLong(attrId); pkey.setRequiredId(natId); pkey.setRequiredId(natId); // Read the object and prepare the XML response ICFBamUInt64ColObj read = ((ICFBamUInt64ColObj) schemaObj.getUInt64ColTableObj().readUInt64Col(pkey, true)); if (read != null) { String response = schemaFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFBamXMsgUInt64ColMessageFormatter.formatUInt64ColRspnSingleOpenTag() + CFBamXMsgUInt64ColMessageFormatter.formatUInt64ColRspnDerivedRec( "\n\t\t", read.getUInt64ColBuff()) + "\n" + "\t" + CFBamXMsgUInt64ColMessageFormatter.formatUInt64ColRspnSingleCloseTag() + schemaFormatter.formatRspnXmlPostamble(); xmsgRqstHandler.appendResponse(response); } else { String response = schemaFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFBamXMsgSchemaMessageFormatter.formatRspnNoDataFound() + "\n" + schemaFormatter.formatRspnXmlPostamble(); xmsgRqstHandler.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); } }