Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Table of Contents
minLevel2
maxLevel5
includeScripts.*
outlinefalseindent
excludetypelist
separatorbracketspipe
classprintablefalse

Scripts for values

...

Code Block
languagegroovy
import com.atlassian.jira.component.ComponentAccessor
import com.deiser.jira.profields.ao.v2.field.AOField
import com.deiser.jira.profields.ao.v2.field.FieldMgr
import groovy.json.JsonOutput
import groovy.json.JsonSlurper
 
def fieldMgr = ComponentAccessor.getOSGiComponentInstanceOfType(FieldMgr.class)
 
def FIELD_IDs = [X, X];
def CONNECTION_ID = Y
 
def println = "Start <br/>"
 
 
 
FIELD_IDs.each {
 
    def fieldList = fieldMgr.getById(it)
 
    if(fieldList.length == 1){
 
        def field = fieldList[0]
        def data = field.getData()
 
        println += "     Field: Id(" + field.ID + ") Name(" + field.name + ") Data(" + field.data + ") <br/>"
 
        def jsonSlurper = new JsonSlurper()
        def objectJson = jsonSlurper.parseText(data)
 
        objectJson.connectionId = CONNECTION_ID
        def newData = JsonOutput.toJson(objectJson)
 
        field.setData(newData)
 
        println += "     Before Save: Id(" + field.ID + ") Name(" + field.name + ") Data(" + field.data + ") <br/>"
 
        fieldMgr.save(field)
 
        println += "     Saved! <br/>"
    }
}
 
println

Scripts for

...

subscriptions

Problem: Know which subscriptions the instance has and who their owner is.

...

Code Block
languagegroovy
import com.deiser.jira.profields.api.subscription.SubscriptionService
import com.atlassian.jira.component.ComponentAccessor

ComponentAccessor.getOSGiComponentInstanceOfType(SubscriptionService.class)
    .get()
    .collect{" - ${it.user}: ${it.name}"}
    .join("<br/>")

Scripts for

...

mapping to Jira custom fields

Problem: We have encountered Jira custom fields that have lost their association with Projectrak fields.

...

Code Block
languagegroovy
import com.atlassian.jira.component.ComponentAccessor
import org.apache.commons.lang3.exception.ExceptionUtils
import org.ofbiz.core.entity.ConnectionFactory
import org.ofbiz.core.entity.DelegatorInterface
 
import java.sql.ResultSet
import java.sql.Statement
 
def delegator = ComponentAccessor.getComponentOfType(DelegatorInterface.class)
def helperName = delegator.getGroupHelperName("default")
def connection = ConnectionFactory.getConnection(helperName)
 
def result = ""
try {
    def NEW_VERSION = 26
 
    def stmt = connection.createStatement()
    def isOk = stmt.execute(
            "update propertystring " +
                     "set propertyvalue = ('"+ NEW_VERSION +"') " +
                    "where id = ( " +
                        "select propertystring.id " +
                            " from propertyentry, propertystring " +
                            " where propertyentry.id = propertystring.id " +
                        "     and propertyentry.property_key = 'AO_00B950_#'" +
                    ")"
    )
 
    if(isOk != true){
        result += " Update the database version of Profields to (" + NEW_VERSION + ")"
    }
    else{
        result += " Error: Can not update the database version of Profields to (" + NEW_VERSION + ")"
    }
 
} catch (def e) {
    result += "<br/> Error: <br/>" + ExceptionUtils.getStackTrace(e)
}
 
return result

Scripts for Oracle

...

database

Problem: When making a change in the database properties, we encountered Clob-type columns in the Projectrak tables, which is causing errors in certain functionalities.

...