public class BundleServiceImpl extends Object implements BundleService
| Constructor and Description |
|---|
BundleServiceImpl(ActionQueuePreparer actionQueuePreparer,
BundleDefLoader defLoader,
GmoCacheManager cacheManager,
String defaultProfile,
DynamicService dynamicService) |
| Modifier and Type | Method and Description |
|---|---|
Bundle |
create()
Creates bundle for the first time, based on default profile.
|
Bundle |
create(String profile)
Creates bundle for the first time, based on given profile.
|
BundleDiff |
diff(Bundle bundle)
Compares given bundle with initial version of the same bundle(by id).
|
BundleDiff |
diff(Bundle prev,
Bundle next)
Compares two different bundles and stores the result of comparison in
BundleDiff object. |
GmoCacheManager |
getCacheManager()
Returns cache manager, that is used within persistence engine as first level cache.
|
BundleDef |
getDefinition(String profile)
Based on given profile, bundle definition will be fetched from current Hyperon Studio environment, to which Hyperon Persistence is connected.
|
Bundle |
load(long id)
Retrieves a bundle based on given id for default profile.
|
Bundle |
load(long id,
BundleDef def)
Retrieves a bundle based on given id and bundle definition.
|
Bundle |
load(long id,
String profile)
Retrieves a bundle based on given id and profile.
|
void |
persist(Bundle bundle)
Saves bundle in tables using database connection defined with
HyperonPersistenceFactory. |
public BundleServiceImpl(ActionQueuePreparer actionQueuePreparer, BundleDefLoader defLoader, GmoCacheManager cacheManager, String defaultProfile, DynamicService dynamicService)
public void persist(Bundle bundle)
BundleServiceHyperonPersistenceFactory.
persist in interface BundleServicebundle - to be persisted, can't be nullpublic Bundle load(long id, BundleDef def)
BundleService
BundleService service = ..;
Bundle firstBundle = service.load(12);
Bundle secondBundle = service.load(12);
firstBundle != secondBundle; // true
Objects.equals(firstBundle, secondBundle); // true
load in interface BundleServiceid - bundle id to loaddef - bundle definition, can't be nullDaoConfig.setBundleTable(String),
Bundle.deepcopy(),
BundleService.load(long),
BundleService.load(long, String)public Bundle load(long id, String profile)
BundleServiceBundleService.load(long, BundleDef). Calling this method multiple times for the same id,
will always return new Bundle instance.
BundleService service = ..;
Bundle firstBundle = service.load(12);
Bundle secondBundle = service.load(12);
firstBundle != secondBundle; // true
Objects.equals(firstBundle, secondBundle); // true
load in interface BundleServiceid - id bundle id to loadprofile - allows to get current domain definitionBundleService.load(long),
BundleService.load(long, BundleDef)public Bundle load(long id)
BundleServiceHyperonPersistenceFactory.setDefaultProfile(String).
Bundle definition will be used from current Hyperon Studio environment, to which Hyperon Persistence is connected.
Rest is the same as in BundleService.load(long, BundleDef). Calling this method multiple times for the same id, will always return new Bundle
instance.
BundleService service = ..;
Bundle firstBundle = service.load(12);
Bundle secondBundle = service.load(12);
firstBundle != secondBundle; // true
Objects.equals(firstBundle, secondBundle); // true
load in interface BundleServiceid - bundle id to loadBundleService.load(long, BundleDef),
BundleService.load(long, String)public BundleDef getDefinition(String profile)
BundleServicegetDefinition in interface BundleServiceprofile - allows to get current domain definitionBundleDefpublic Bundle create(String profile)
BundleServicecreate in interface BundleServiceprofile - allows to get current domain definition- for default table namepublic Bundle create()
BundleServicecreate in interface BundleServiceDaoConfig.setBundleTable(String)public GmoCacheManager getCacheManager()
BundleServicegetCacheManager in interface BundleServicepublic BundleDiff diff(Bundle prev, Bundle next)
BundleService
Compares two different bundles and stores the result of comparison in BundleDiff object. The result will be in form of separated collections of:
elements to insert, to update, to delete.
BundleService service = ..;
Bundle firstBundle = service.load(11);
Bundle secondBundle = service.load(22);
BundleDiff result = service.diff(firstBundle, secondBundle); // difference between these two bundles
--------------
Bundle firstBundle = service.load(33);
Bundle secondBundle = service.load(33);
BundleDiff result = service.diff(firstBundle, secondBundle); // same bundles, then no differences should be there
diff in interface BundleServiceprev - first bundle, not nullnext - second bundle, not nullBundleDiffpublic BundleDiff diff(Bundle bundle)
BundleServiceCompares given bundle with initial version of the same bundle(by id). Initial version means that it looks for bundle (with the same id) in:
BundleDiff object. It will
be in form of separated collections of: elements to insert, to update, to delete.
Example:
BundleService service = ..;
Bundle bundle = service.load(12);
bundle.get("policy").remove("product");
BundleDiff result = service.diff(bundle); // there will be information about deleted product from policy
This method doesn't look for previous versions of provided bundle!
diff in interface BundleServicebundle - bundle, not nullBundleDiffCopyright © 2021. All rights reserved.