public ICFSecurityServiceTypeObj readServiceTypeByUDescrIdx( String Description, boolean forceRead) { if (indexByUDescrIdx == null) { indexByUDescrIdx = new HashMap<CFSecurityServiceTypeByUDescrIdxKey, ICFSecurityServiceTypeObj>(); } CFSecurityServiceTypeByUDescrIdxKey key = ((ICFAccSchema) schema.getBackingStore()).getFactoryServiceType().newUDescrIdxKey(); key.setRequiredDescription(Description); ICFSecurityServiceTypeObj obj = null; if ((!forceRead) && indexByUDescrIdx.containsKey(key)) { obj = indexByUDescrIdx.get(key); } else { CFSecurityServiceTypeBuff buff = ((ICFAccSchema) schema.getBackingStore()) .getTableServiceType() .readDerivedByUDescrIdx(schema.getAuthorization(), Description); if (buff != null) { obj = schema.getServiceTypeTableObj().newInstance(); obj.setPKey(((ICFAccSchema) schema.getBackingStore()).getFactoryServiceType().newPKey()); obj.setBuff(buff); obj = (ICFSecurityServiceTypeObj) obj.realize(); } else if (schema.getCacheMisses()) { indexByUDescrIdx.put(key, null); } } return (obj); }
public ICFSecurityServiceTypeObj lockServiceType(CFSecurityServiceTypePKey pkey) { ICFSecurityServiceTypeObj locked = null; CFSecurityServiceTypeBuff lockBuff = ((ICFAccSchema) schema.getBackingStore()) .getTableServiceType() .lockDerived(schema.getAuthorization(), pkey); if (lockBuff != null) { locked = schema.getServiceTypeTableObj().newInstance(); locked.setPKey(((ICFAccSchema) schema.getBackingStore()).getFactoryServiceType().newPKey()); locked.setBuff(lockBuff); locked = (ICFSecurityServiceTypeObj) locked.realize(); } else { throw CFLib.getDefaultExceptionFactory() .newCollisionDetectedException(getClass(), "lockServiceType", pkey); } return (locked); }
public ICFSecurityServiceTypeObj readServiceType( CFSecurityServiceTypePKey pkey, boolean forceRead) { ICFSecurityServiceTypeObj obj = null; if ((!forceRead) && members.containsKey(pkey)) { obj = members.get(pkey); } else { CFSecurityServiceTypeBuff readBuff = ((ICFAccSchema) schema.getBackingStore()) .getTableServiceType() .readDerivedByIdIdx(schema.getAuthorization(), pkey.getRequiredServiceTypeId()); if (readBuff != null) { obj = schema.getServiceTypeTableObj().newInstance(); obj.setPKey(((ICFAccSchema) schema.getBackingStore()).getFactoryServiceType().newPKey()); obj.setBuff(readBuff); obj = (ICFSecurityServiceTypeObj) obj.realize(); } else if (schema.getCacheMisses()) { members.put(pkey, null); } } return (obj); }
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { try { // Common XML Attributes String attrId = null; String attrRevision = null; // ServiceType Attributes String attrServiceTypeId = null; String attrDescription = 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("ServiceType"); CFSecurityXMsgRspnHandler xmsgRspnHandler = (CFSecurityXMsgRspnHandler) getParser(); if (xmsgRspnHandler == null) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "getParser()"); } ICFSecuritySchemaObj schemaObj = xmsgRspnHandler.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("ServiceTypeId")) { if (attrServiceTypeId != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrServiceTypeId = 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("schemaLocation")) { // ignored } else { throw CFLib.getDefaultExceptionFactory() .newUnrecognizedAttributeException( getClass(), S_ProcName, getParser().getLocationInfo(), attrLocalName); } } // Ensure that required attributes have values if ((attrServiceTypeId == null) || (attrServiceTypeId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "ServiceTypeId"); } if (attrDescription == null) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "Description"); } // Save named attributes to context CFLibXmlCoreContext curContext = xmsgRspnHandler.getCurContext(); // Convert string attributes to native Java types int natServiceTypeId = Integer.parseInt(attrServiceTypeId); String natDescription = attrDescription; int natRevision = Integer.parseInt(attrRevision); 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); } // Get the parent context CFLibXmlCoreContext parentContext = curContext.getPrevContext(); // Instantiate a buffer for the parsed information ICFSecurityServiceTypeObj obj = (ICFSecurityServiceTypeObj) (schemaObj.getServiceTypeTableObj().newInstance()); CFSecurityServiceTypeBuff dataBuff = obj.getServiceTypeBuff(); dataBuff.setRequiredServiceTypeId(natServiceTypeId); dataBuff.setRequiredDescription(natDescription); dataBuff.setRequiredRevision(natRevision); if (createdBy != null) { dataBuff.setCreatedByUserId(createdBy); } if (createdAt != null) { dataBuff.setCreatedAt(createdAt); } if (updatedBy != null) { dataBuff.setUpdatedByUserId(updatedBy); } if (updatedAt != null) { dataBuff.setUpdatedAt(updatedAt); } obj.copyBuffToPKey(); @SuppressWarnings("unchecked") List<ICFSecurityServiceTypeObj> list = (List<ICFSecurityServiceTypeObj>) xmsgRspnHandler.getListOfObjects(); ICFSecurityServiceTypeObj realized = (ICFSecurityServiceTypeObj) obj.realize(); xmsgRspnHandler.setLastObjectProcessed(realized); if (list != null) { list.add(realized); } } catch (RuntimeException e) { throw new RuntimeException( "Near " + getParser().getLocationInfo() + ": Caught and rethrew " + e.getClass().getName() + " - " + e.getMessage(), e); } catch (Error e) { throw new Error( "Near " + getParser().getLocationInfo() + ": Caught and rethrew " + e.getClass().getName() + " - " + e.getMessage(), e); } }