/** * Deserialises a map of Facet keys to Facets from the given PersistenceContext. * * @param pPersistenceContext For deserialising the Facets. * @param pModuleCall ModuleCall to deserialise the Facets for. * @param pFacetType Type of Facet to be deserialised. * @param pFacetClass Marker class for providing type safety. Deserialised Facets should be * castable to this class. * @param <T> Facet type to be returned. * @return Map of keys to Facets. */ protected static <T extends ModuleFacet> Map<String, T> deserialiseFacets( PersistenceContext pPersistenceContext, ModuleCall pModuleCall, ModuleFacetType pFacetType, Class<T> pFacetClass) { Collection<T> lModuleCallFacets = pPersistenceContext .getDeserialiser() .getModuleCallFacets(pModuleCall.getCallId(), pFacetType, pFacetClass); Map lFacetMap = new HashMap<String, T>(); for (ModuleFacet lFacet : lModuleCallFacets) { lFacetMap.put(lFacet.getFacetKey(), lFacet); } return lFacetMap; }
/** * Registers a new Facet in the map and marks it as requiring serialisation. * * @param pNewFacet The newly created facet. */ protected void registerNewFacet(T pNewFacet) { mFacetKeyToFacetMap.put(pNewFacet.getFacetKey(), pNewFacet); mPersistenceContext.requiresPersisting(pNewFacet, PersistenceMethod.CREATE); }
/** * Removes the given facet from this provider and marks it as requiring a delete. * * @param pFacet Facet to delete. */ protected void deleteFacet(T pFacet) { mFacetKeyToFacetMap.remove(pFacet.getFacetKey()); mPersistenceContext.requiresPersisting(pFacet, PersistenceMethod.DELETE); }
/** * Marks the given facet as requiring an update. Note that a new object may be created which * represents an existing facet - this should be considered an update as there should already be a * serialised entity. * * @param pFacet Facet which has been updated. */ protected void updateExistingFacet(T pFacet) { // Put into the map again, in case the caller has actaully created a new object mFacetKeyToFacetMap.put(pFacet.getFacetKey(), pFacet); mPersistenceContext.requiresPersisting(pFacet, PersistenceMethod.UPDATE); }