Skip to content
This repository was archived by the owner on Feb 5, 2020. It is now read-only.

[CONSULT-1524] changed execution from member to method parameter#2

Open
eugenweissbart wants to merge 4 commits intohydra-billing:masterfrom
eugenweissbart:no_member_variables
Open

[CONSULT-1524] changed execution from member to method parameter#2
eugenweissbart wants to merge 4 commits intohydra-billing:masterfrom
eugenweissbart:no_member_variables

Conversation

@eugenweissbart
Copy link
Copy Markdown

No description provided.

build.xml Outdated
</path>
<taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc" classpathref="groovy.classpath" />
-->
<property name="groovy.home" value="/usr/local/Cellar/groovy" />
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really? Cellar/groovy?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is where it's located on my mac. Will revert in next commit.

false
}
}
} No newline at end of file
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing new line

switch (event) {
case ActivitiActivityEventImpl:
detailedLog = getActivityLog()
detailedLog = "${event.getActivityId()} (${event.getActivityType()} - ${event.getActivityName()})"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could still use that functions, but pass event as a param.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't find them much necessary as they just return a single string

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are pretty complicated. We use this functions to simplify code.

def protected execute() {

def protected execute(execution) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't you need to describe type of execution like:
DelegateExecution execution?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point!


logger
}
} No newline at end of file
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing new line

def HTTPRestProcessor(parameters) {
this.execution = parameters.execution
this.httpClient = new RESTClient(parameters.baseUrl)
this.httpClient.ignoreSSLIssues()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Easy man, easy. What happened here?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, this was for testing purposes (self-signed SSL cert error) and didnt go away, will fix

logger = execution.getVariable("logger")
}

logger
Copy link
Copy Markdown

@sugarfree1 sugarfree1 May 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method could be shortened to something like:

def protected getLogger(DelegateExecution execution) {
  if (execution) {
    execution.getVariable("logger")
  }
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this actually return the logger?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated


def public sendRequest(params, String method) {
def execution = params.execution
params.remove('execution')
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

groovy's HTTPBuilder has this strange check that caused the code to fail if execution stays in params map.


import org.activiti.latera.bss.eventListeners.AbstractListener
import org.activiti.latera.bss.http.HTTPRestProcessor
import org.activiti.engine.delegate.event.*
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you use only ActivitiEvent from this package.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point!

def orderData = getOrderData(execution)
def orderDataBuffer = execution.getVariable('homsOrdDataBuffer')

if (orderData != orderDataBuffer) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need variable orderDataBuffer. Just compare directly to result of execution.getVariable.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't agree here because the variables are changed already, here we have a few options

  • use homsOrdDataBuffer
  • get variables from HOMS before comparsion (not good as will add one HTTP GET request each AutoSaveOrderData run (basically each ACTIVITI_COMPLETED event)
  • push variables seamlessly each ACTIVITI_COMPLETED (even worse)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed, will replace orderDataBuffer with execution.getVariable('homsOrdDataBuffer')

* Changed groovy path in build.xml
* Added trailing newlines where missing
* Fixed execute method declaration in src/bss/executionListeners/abstract_listener.groovy
* Fixed alignment in src/bss/executionListeners/init_logging.groovy
* Removed unnecessary ignoreSSLIssues call in src/bss/http.groovy
* Shortened getLogger declaration in src/bss/http.groovy
* Fixed imports for src/homs/eventListeners/auto_save_order_data.groovy
* Removed unnecessary orderDataBuffer variable in src/homs/eventListeners/auto_save_order_data.groovy
build.xml Outdated
<property name="dst.build" location="${dst}/build" />
<property name="dst.lib" location="${dst}/lib" />

<!--
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just remove this code if you don't need it.

execute()
def execution = getExecution(event)

execute(execution, event)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove def execution and change this line to:

execute(getExecution(event), event)

switch (event) {
case ActivitiActivityEventImpl:
detailedLog = getActivityLog()
detailedLog = "${event.getActivityId()} (${event.getActivityType()} - ${event.getActivityName()})"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are pretty complicated. We use this functions to simplify code.

}

def protected getLogger(DelegateExecution execution) {
def logger = null
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

def protected getLogger(DelegateExecution execution) {
  if (execution) {
    execution.getVariable("logger")
  }
}

I'm pretty sure it works the same.

def homsUser = getParameterValue('homsUser', execution)
def homsPassword = getParameterValue('homsPassword', execution)
def execute(execution) {
def homsUrl = execution.getVariable('homsUrl')
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alignment.

* Removed commented options in build.xml
* Removed unneeded execution variable definition in src/bss/eventListeners/abstract_listener.groovy
* Re-implemented detailed log functions in src/bss/eventListeners/event_logging.groovy
* Shortened getLogger for src/bss/executionListeners/abstract_listener.groovy too
* Fixed alignment in src/homs/executionListeners/finish_order.groovy
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants