Skip to content

Instantly share code, notes, and snippets.

@vikrantyadav11
Created September 12, 2023 05:26
Show Gist options
  • Save vikrantyadav11/01394247d635c639fabb622e9ecbe798 to your computer and use it in GitHub Desktop.
Save vikrantyadav11/01394247d635c639fabb622e9ecbe798 to your computer and use it in GitHub Desktop.
import com.atlassian.jira.component.ComponentAccessor
import groovy.sql.Sql
import org.ofbiz.core.entity.ConnectionFactory
import org.ofbiz.core.entity.DelegatorInterface
import java.sql.Connection
def delegator = (DelegatorInterface) ComponentAccessor.getComponent(DelegatorInterface)
String helperName = delegator.getGroupHelperName("default")
def sqlStmt = """
select pe.property_key,p.* from propertyentry pe join project p on pe.entity_id=p.id where property_key = 'jira.archiving.projects';
"""
Connection conn = ConnectionFactory.getConnection(helperName)
Sql sql = new Sql(conn)
String result = """
<table>
<tr>
<th>Project ID</th>
<th>Project Name</th>
</tr>
"""
sql.eachRow(sqlStmt){ it ->
result += """
<tr>
<td>${it.getAt("pname")}</td>
<td>${it.getAt("ID")}</td>
</tr>
"""
}
return result+"</table>"
sql.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment