Package org.wso2.carbon.bam.common.dataobjects.activity

Examples of org.wso2.carbon.bam.common.dataobjects.activity.ActivityDO


  public static void addActivity(int activityID,ActivityDO activity) {
    activityIDMap.put(Integer.valueOf(activityID), activity);
  }

  public static ActivityDO getActivity(String userDefineActivityID) {
    ActivityDO activityDO = activityUserDefinedIDMap.get(userDefineActivityID);
    return activityDO;
  }
View Full Code Here


                } catch (BAMException e) {
                    log.error("Could not retrieve operation from DB ", e);
                }

                try {
                    ActivityDO activity = null;
                    if (activityMap.containsKey(data.getActivityId())) {
                        activity = activityMap.get(data.getActivityId());
                    } else {
                        activity = dsAdmin.getActivityForActivityID(data.getActivityId());
                        if (activity == null) {
                            activity = new ActivityDO();
                            activity.setActivityId(data.getActivityId());
                            activity.setName(data.getActivityName());
                            activity.setDescription(data.getActivityDescription());
                            dsAdmin.addActivity(activity);
                            activity = dsAdmin.getActivityForActivityID(data.getActivityId());
                        }
                        activityMap.put(data.getActivityId(), activity);
                    }
                    messageDO.setActivityKeyId(activity.getActivityKeyId());
                } catch (BAMException e) {
                    log.error("Could not retrieve activity from DB ", e);
                }

                try {
View Full Code Here

     * @param data    Event data
     * @param dsAdmin Data service access
     */
    private void storeActivity(ActivityData data, BAMDataServiceAdmin dsAdmin) {

        ActivityDO activityDO;

        if (data.getActivityId() != null) {
            if (!data.getActivityId().equals("")) {
                activityDO = new ActivityDO(data.getActivityId(), data.getActivityName(), data.getActivityDescription());
                ActivityDO act;

                try {
                    act = dsAdmin.getActivityForActivityID(data.getActivityId());
                    if (act != null) {
                        //NOTE: Activity name & description never get changed. Hence no need to call update
                        //method
                        //TODO: if this update method is needed, implement dirty pattern first to check if the
                        //record in the database really needs to be updated.

                        //    dsAdmin.updateActivity(data.getActivityName(), data.getActivityDescription(),
                        //            act.getActivityKeyId());
                    } else {
                        try {
                            dsAdmin.addActivityData(activityDO);
                            if (log.isDebugEnabled()) {
                                log.debug("Activity is saved");
                            }
                            // After adding to the DB set the activityKeyID.
                            act = dsAdmin.getActivityForActivityID(data.getActivityId());
                        } catch (Exception ignore) {
                            log.error("Recovered successfully from race condition - trying to add the same"
                                      + " activity from two events.");
                        }
                    }
                    activityDO.setActivityKeyId(act.getActivityKeyId());
                } catch (Exception e) {
                    log.error("Couldn't add activity  : ", e);
                }
            }
        }
View Full Code Here

            if (!data.getOperationName().equals("") && !data.getServiceName().equals("")
                && !data.getActivityId().equals("")) {

                ServiceDO service;
                OperationDO operation;
                ActivityDO activity;
                MessageDataDO messageDataDO;

                if (data.getTimeStamp() != null) {
                    messageDataDO = new MessageDataDO(data.getTimeStamp(), data.getRemoteIPAddress(), data
                            .getMessageDirection(), data.getMessageBody(), data.getRequestMessageStatus(), data
View Full Code Here

            if (!data.getOperationName().equals("") && !data.getServiceName().equals("")
                && !data.getActivityId().equals("")) {

                ServiceDO service;
                OperationDO operation;
                ActivityDO activity;
                MessageDataDO messageDataDO;

                if (data.getTimeStamp() != null) {
                    if (data.getTimeStamp().equals("")) {
                        messageDataDO = new MessageDataDO(BAMCalendar.getInstance(Calendar.getInstance())
View Full Code Here

     * @param messageDataDO
     */
    private void checkForActivityExistense(ActivityData data,
                                           BAMDataServiceAdmin dsAdmin,
                                           MessageDataDO messageDataDO) {
        ActivityDO activity = null;
        try {
            if (activityMap.containsKey(data.getActivityId())) {
                activity = activityMap.get(data.getActivityId());
            } else {
                if (dsAdmin.getActivityForActivityID(data.getActivityId()) == null) {
                    activity = new ActivityDO();
                    activity.setActivityId(data.getActivityId());
                    activity.setName(data.getActivityName());
                    activity.setDescription(data.getActivityDescription());
                    dsAdmin.addActivity(activity);
                }
                activity = dsAdmin.getActivityForActivityID(data.getActivityId());
                activityMap.put(activity.getActivityId(), activity);
            }
            messageDataDO.setActivityKeyId((activity.getActivityKeyId()));
        } catch (BAMException e) {
            log.error("Could not retrieve activity from DB ", e);
        }
    }
View Full Code Here

                    } catch (BAMException e) {
                        log.error("Could not retrieve operation from DB ", e);
                    }

                    ActivityDO activity = null;
                    try {
                        if (activityMap.containsKey(data.getActivityId())) {
                            activity = activityMap.get(data.getActivityId());
                        } else {
                            activity = dsAdmin.getActivityForActivityID(data.getActivityId());
                            if (activity == null) {
                                activity = new ActivityDO();
                                activity.setActivityId(data.getActivityId());
                                activity.setName(data.getActivityName());
                                activity.setDescription(data.getActivityDescription());
                                dsAdmin.addActivity(activity);
                                activity = dsAdmin.getActivityForActivityID(data.getActivityId());
                            }
                            activityMap.put(data.getActivityId(), activity);
                        }
                        messagePropertyDO.setActivityKeyId(activity.getActivityKeyId());
                    } catch (BAMException e) {
                        log.error("Could not retrieve activity from DB ", e);
                    }

                    try {
View Full Code Here

                && !data.getActivityId().equals("")) {

                if (data.getXPathEvaluations() != null) {
                    ServiceDO service;
                    OperationDO operation;
                    ActivityDO activity;


                    MessagePropertyDO messagePropertyDO = null;

                    messagePropertyDO = new MessagePropertyDO();
                    try {
                        ServerDO serverDO = dsAdmin.getServer(data.getServerName());
                        if (serverDO != null) {
                            messagePropertyDO.setServerId(serverDO.getId());
                        } else {
                            log.error("Server is not in the Database" + data.getServerName());
                        }
                    } catch (BAMException e) {
                        log.error("Could not retrieve server from DB ", e);
                    }

                    try {
                        if (dsAdmin.getService(messagePropertyDO.getServerId(), data.getServiceName()) == null) {
                            service = new ServiceDO();
                            ServerDO serverDO = dsAdmin.getServer(data.getServerName());
                            if (serverDO != null) {
                                service.setServerID(serverDO.getId());
                                service.setName(data.getServiceName());
                                dsAdmin.addService(service);
                                messagePropertyDO.setServiceId(dsAdmin.getService(messagePropertyDO.getServerId(),
                                                                                  data.getServiceName()).getId());
                            }

                        } else {
                            messagePropertyDO.setServiceId(dsAdmin.getService(messagePropertyDO.getServerId(),
                                                                              data.getServiceName()).getId());
                        }
                    } catch (BAMException e) {
                        log.error("Could not retrieve service from DB ", e);
                    }

                    try {
                        if (dsAdmin.getOperation(messagePropertyDO.getServiceId(), data.getOperationName()) == null) {
                            operation = new OperationDO();
                            ServiceDO serviceDO = dsAdmin.getService(messagePropertyDO.getServerId(),
                                                                     data.getServiceName());
                            if (serviceDO != null) {
                                operation.setServiceID(messagePropertyDO.getServiceId());
                                operation.setName(data.getOperationName());
                                dsAdmin.addOperation(operation);
                                messagePropertyDO.setOperationId(dsAdmin.getOperation(
                                        messagePropertyDO.getServiceId(), data.getOperationName())
                                        .getOperationID());
                            } else {
                                serviceDO = new ServiceDO();
                                serviceDO.setServerID(messagePropertyDO.getServerId());
                                serviceDO.setName(data.getServiceName());
                                dsAdmin.addService(serviceDO);

                                messagePropertyDO.setServiceId(dsAdmin.getService(messagePropertyDO.getServerId(),
                                                                                  data.getServiceName()).getId());

                                operation.setServiceID(messagePropertyDO.getServiceId());
                                operation.setName(data.getOperationName());
                                dsAdmin.addOperation(operation);

                                messagePropertyDO.setOperationId(dsAdmin.getOperation(
                                        messagePropertyDO.getServiceId(), data.getOperationName())
                                        .getOperationID());
                            }
                        } else {
                            messagePropertyDO.setOperationId(dsAdmin.getOperation(messagePropertyDO.getServiceId(),
                                                                                  data.getOperationName()).getOperationID());
                        }
                    } catch (BAMException e) {
                        log.error("Could not retrieve operation from DB ", e);
                    }

                    try {
                        if (dsAdmin.getActivityForActivityID(data.getActivityId()) == null) {
                            activity = new ActivityDO();
                            activity.setActivityId(data.getActivityId());
                            activity.setName(data.getActivityName());
                            activity.setDescription(data.getActivityDescription());
                            dsAdmin.addActivity(activity);
                            messagePropertyDO.setActivityKeyId(dsAdmin.getActivityForActivityID(
                                    data.getActivityId()).getActivityKeyId());
                        } else {
                            messagePropertyDO.setActivityKeyId(dsAdmin.getActivityForActivityID(
                                    data.getActivityId()).getActivityKeyId());
                        }
                    } catch (BAMException e) {
                        log.error("Could not retrieve activity from DB ", e);
                    }

                    try {
                        MessageDO msg = dsAdmin.getMessage(data.getMessageId(), messagePropertyDO.getOperationId(),
                                                           messagePropertyDO.getActivityKeyId());
                        if (msg != null) {
                            messagePropertyDO.setMessageKeyId(msg.getMessageKeyId());
                        } else {
                            MessageDO mesg = new MessageDO();
                            ActivityDO activityDO = dsAdmin.getActivityForActivityID(data.getActivityId());
                            if (activityDO != null) {
                                mesg.setMessageId(data.getMessageId());
                                mesg.setActivityKeyId(messagePropertyDO.getActivityKeyId());
                                mesg.setOperationId(messagePropertyDO.getOperationId());
                                // TODO timestamp fix
View Full Code Here

     * @return The end line number, or -1 if could not be determined
     */
    public int getEndLineNumber() {
      int ret=-1;
     
      ActivityInterface parent=getParent();
     
      if (parent != null) {
        int index=parent.getSubActivities().indexOf(this);
       
        if (index != -1) {
          if (index < (parent.getSubActivities().size()-1)) {
            ActivityInterface other=parent.getSubActivities().get(index+1);
           
            ret = other.getStartLineNumber()-1;
          } else {
            ret = parent.getEndLineNumber();
          }
        }
      }
View Full Code Here

     *
     * @param lineNumber The line number
     * @return The activity, or null if not found
     */
    public ActivityInterface getActivityAtLineNumber(int lineNumber) {
      ActivityInterface ret=null;
     
      int endline=getEndLineNumber();
     
      if (getStartLineNumber() <= lineNumber && (endline == -1 || endline >= lineNumber)) {
       
View Full Code Here

TOP

Related Classes of org.wso2.carbon.bam.common.dataobjects.activity.ActivityDO

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.