/** * {@inheritDoc} */ public void store(final List<ActivityUnit> activities) throws Exception { if (LOG.isLoggable(Level.FINEST)) { LOG.finest("Store=" + new String(ActivityUtil.serializeActivityUnitList(activities))); } _jpaStore.withJpa(new JpaWork<Void>() { public Void perform(Session s) { for (int i = 0; i < activities.size(); i++) { s.persist(activities.get(i)); } return null; } }); }
/** * {@inheritDoc} */ public ActivityUnit getActivityUnit(final String id) throws Exception { if (LOG.isLoggable(Level.FINEST)) { LOG.finest("Get Activity Unit=" + id); } ActivityUnit ret = _jpaStore.withJpa(new JpaWork<ActivityUnit>() { public ActivityUnit perform(Session s) { return (ActivityUnit) s.createQuery( "SELECT au FROM ActivityUnit au WHERE au.id = '" + id + "'").uniqueResult(); } }); if (LOG.isLoggable(Level.FINEST)) { LOG.finest("ActivityUnit id=" + id + " Result=" + new String(ActivityUtil.serializeActivityUnit(ret))); } return (ret); }
/** * This method performs the query associated with the supplied query * expression, returning the results as a list of activity types. * * @param query * The query expression * @return The list of activity types * @throws Exception * Failed to perform query */ @SuppressWarnings("unchecked") public List<ActivityType> query(final String query) throws Exception { List<ActivityType> ret = _jpaStore.withJpa(new JpaWork<List<ActivityType>>() { public List<ActivityType> perform(Session s) { return (List<ActivityType>) s.createQuery(query).list(); } }); if (LOG.isLoggable(Level.FINEST)) { LOG.finest("Query=" + query + " Result=" + new String(ActivityUtil.serializeActivityTypeList(ret))); } return (ret); }
QuerySpec qs=ActivityUtil.deserializeQuerySpec(qspec.getBytes()); byte[] b=ActivityUtil.serializeActivityTypeList(list);
return (ActivityUtil.objectToJSONString(information)); } catch (Exception e) { LOG.log(Level.SEVERE, "Failed to transformer information '"+information+"' to JSON", e);
byte[] b=ActivityUtil.serializeQuerySpec(query); os.write(b); is.read(b); ret = ActivityUtil.deserializeActivityTypeList(b);
ret = ActivityUtil.deserializeActivityUnit(b);
is.read(b); ret = ActivityUtil.deserializeActivityTypeList(b);
os.write(ActivityUtil.serializeActivityUnitList(activities));
+ new String(ActivityUtil.serializeActivityTypeList(ret)));
/** * This method processes the supplied activity unit to derive * service definition information. * * @param actUnit The activity unit * @return The service definitions */ public static java.util.Collection<ServiceDefinition> derive(ActivityUnit actUnit) { java.util.Map<String,ServiceDefinition> ret= new java.util.HashMap<String,ServiceDefinition>(); checkForServiceInvoked(ret, actUnit, 0, actUnit.getActivityTypes().size(), null); if (LOG.isLoggable(Level.FINEST)) { String au=null; try { au = new String(ActivityUtil.serializeActivityUnit(actUnit)); } catch (Exception e) { LOG.log(Level.FINEST, "Failed to deserialize activity unit: "+actUnit, e); } LOG.finest("Derive service definitions: ActivityUnit="+au+" ServiceDefinitions="+ret); } return (ret.values()); }
LOG.finest("Return reconstructed activity unit for id["+id+"]="+ActivityUtil.objectToJSONString(ret));
byte[] b=ActivityUtil.serializeActivityUnitList(acts); LOG.finest("Store "+acts.size()+" activities: "+new String(b));
byte[] b=ActivityUtil.serializeActivityTypeList(list);
byte[] b=ActivityUtil.serializeActivityUnit(au);
/** * @param activities The list of activity events to store * @throws Exception if any activities cannot be stored */ public void store(List<ActivityUnit> activities) throws Exception { if (LOG.isLoggable(Level.FINEST)) { LOG.finest("Store=" + new String(ActivityUtil.serializeActivityUnitList(activities))); } BulkRequestBuilder localBulkRequestBuilder = _client.getElasticsearchClient().prepareBulk(); for (int i=0; i < activities.size(); i++) { ActivityUnit activityUnit=activities.get(i); persist(localBulkRequestBuilder, activityUnit.getId(), activityUnit); } BulkResponse bulkItemResponses = localBulkRequestBuilder.execute().actionGet(); if (bulkItemResponses.hasFailures()) { LOG.severe(" Bulk Documents{" + activities.size() + "} could not be created for index [" + _client.getIndex() + "/" + _client.getType() + "/"); if (LOG.isLoggable(Level.FINEST)) { LOG.finest("FAILED MESSAGES. " + bulkItemResponses.buildFailureMessage()); } throw new Exception(" Bulk Documents{" + activities.size() + "} could not be created for index [" + _client.getIndex() + "/" + _client.getType() + "/ \n " + bulkItemResponses.buildFailureMessage()); } else { if (LOG.isLoggable(Level.FINEST)) { LOG.finest("Success storing " + activities.size() + " items to [" + _client.getIndex() + "/" + _client.getType() + "]"); } } }
+new String(ActivityUtil.serializeActivityTypeList(list)));