+1

Custom Columns: How to get values from filters?

Juan (Comunica Translations) 3 years ago in Home Portal updated 3 years ago 7

Hello everybody:

normally, when I create a custom column, I always find a method that suits my needs. But I am just trying to use a method where some parameters need to be passed to it. In this case, In the Vendor selection view, that shows the price profiles, I would like to get the Rates belonging yo it.
The thing is that the method that I found and could be useful for that is:


com.radzisz.xtrf.model.partner.PriceProfile

getRate
(Language sourceLanguage, Language targetLanguage, LanguageSpecialization languageSpecialization, CalculationUnit calculationUnit, ActivityType activityType)

As you can see, this method accepts the Source and target language, etc.. I have the feeling that those are members that I can only get from the filters where the custom column is programmed. But that's the thing, I don't know how to get their values.

I normally program the custom columns in Groovy and in this case, the Class Name is: Price Profile.

Thanks in advance for reading and answering.

My best regards.

Hi, can you explain what you are trying to do? Do you simply want to see the rates for each price profile when selecting vendors? Or are you trying to see ALL the rates for each price profile in a view of vendors?

Thanks for your answer Alexandros.

What I am trying to achieve, is to get a column that will show all the specializations for the chosen language combination.
So if a source and a target is set on the filters, the column will show all the specializations for that language combination inside the price profile.

Thanks.

My best regards.

+1

The filter will filter on Provider > Source language and Provider > Target language. 

Therefore, you have to use this value from the provider.

As the provider can have multiple language combinations, you will have to loop through them.


Try something like this, you can probably fill in the rest.

def result = "-"
def rates = new ArrayList()
def languageCombinations = unwrappedThis.provider.languageCombinations

for ( def languageCombination : languageCombinations ) {
if ( languageCombination.sourceLanguage != null && languageCombination.targetLanguage != null) {
//unwrappedThis.priceToQualityRatio.getRate(languageCombination.sourceLanguage, languageCombination.targetLanguage, ~
rates.add(languageCombination.displayName)
}
}

if(rates.size() != 0) {
result = String.join("\n ", rates)
}

result

Thanks a lot for your answer, Dennis.

But what if I want the source and target language chosen in the filters?

I might be searching for all the specializations, for a specific vendor, for a specific language combination (all these values should be in filters).

Thanks a lot. My best regards.

I don't think you can get to the values of the specific filters. The custom column will evaluate on the entity itself. To my knowledge it is not aware on where it is used and therefore it won't know the specific filter value.

+1

Thanks Dennis.

Really appreciate your answers. It totally makes sense.

My best regards.

In the end, what I have decided to do is to get the price profile's provider and go through every single rate getting the specializations.
The array containing all the specializations will be purged deleting all the duplicates.

This is the code:



def result = "-"
def arraySpecializations = new ArrayList()
def rates = processedEntity.provider.rates

for (def rate : rates){

    def specializations = rate.languageSpecializations

    for (def specialization:specializations)
          arraySpecializations.add(specialization.displayName)
     }

     arraySpecializations = arraySpecializations.unique()

     if(arraySpecializations.size() != 0) {
          result = String.join(", ", arraySpecializations)
     }

     return result
}