Fetch users in workflow definition - liferay

I am using Liferay 6.1.1CE with kaleo workflow.
I am created a new workflow definition,by editing singlelevel workflow.xml.
In my workflow definition,i had add a new transition "reference" and a task for the same.
In my reference task,i have to select a user from all users to send the reference.
How can i fetch the users..? Is it possible?

I am not entirely sure what you task is doing, but yeah, you could definitely access to portal service class by using groovy scripts. something like:
<task>
<name>Some task</name>
<actions>
<action>
<name>task action</name>
<script><![CDATA[
import com.liferay.portal.kernel.util.GetterUtil;
import java.util.List
import java.util.Map;
import java.util.Set;
import java.util.Iterator;
import com.liferay.portal.kernel.workflow.WorkflowConstants;
import com.liferay.portal.model.User;
import com.liferay.portal.service.UserLocalServiceUtil;
long companyId = GetterUtil.getLong((String)
workflowContext.get(WorkflowConstants.CONTEXT_COMPANY_ID));
ServiceContext serviceContext = (ServiceContext)
workflowContext.get(WorkflowConstants.CONTEXT_SERVICE_CONTEXT);
List<User> users = UserLocalServiceUtil.getUsers(start, end);
]]></script>
<script-language>groovy</script-language>
<execution-type>onEntry</execution-type>
</action>
</actions>
<assignments>
<roles>
<role>
<role-type>regular</role-type>
<name>Administrator</name>
</role>
</roles>
</assignments>
<transitions>
<transition>
<name>next</name>
<target>Next Task</target>
</transition>
</transitions>
</task>
and you could access to you workflow task in code use WorkflowInstanceManagerUtil and WorkflowTaskManagerUtil, I hope this helps, let me know if you have further questions

Related

Using relative path in WPF xaml file with pythonnet

I am currently working on an application using WPF + pythonnet. And I encountered a problem of using relative path in the main xaml file to find the ResourceDictionary file. Here is a minimal example. There are three files in the app folder:
app/
|-main_window.py
|-main_window.xaml
|-resource.xaml
The main_window.py stores the python code that loads and shows the window layout from the xaml files:
import os
from pathlib import Path
import clr
clr.AddReference(r"wpf\PresentationFramework")
from System.Windows import Application
from System.IO import StreamReader
from System.Windows.Markup import XamlReader
from System.Threading import ApartmentState, Thread, ThreadStart
class MainWindow:
def __init__(self):
self.xamlFilePath = os.path.join(
Path(__file__).parent,
"main_window.xaml",
)
stream = StreamReader(self.xamlFilePath)
window = XamlReader.Load(stream.BaseStream)
Application().Run(window)
if __name__ == "__main__":
thread = Thread(ThreadStart(MainWindow))
thread.SetApartmentState(ApartmentState.STA)
thread.Start()
thread.Join()
The main_window.xaml file defines the layout of the application:
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Height="200" Width="300">
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="./resource.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
<Grid>
<TextBlock>Test relative path for WPF + Pythonnet</TextBlock>
</Grid>
</Window>
And the resource.xaml stores the ResourceDictionary with the templates:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style TargetType="TextBlock">
<Setter Property="Foreground" Value="Red" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="VerticalAlignment" Value="Center" />
</Style>
</ResourceDictionary>
Ideally, main_window.xaml should be able to find resource.xaml and load the Style tags. It works well if I provide absolute path, but for relative path it did not work. It gave an Exception: Python.Runtime.PythonException: XamlParseException
Interestingly, if I load the xaml file from Kaxaml, the resource.xaml can be found without problem.
Thanks in advance!

Error while creating tenant by using java program

Creating rest API for tenant
import java.util.HashSet;
import org.apache.pulsar.common.policies.data.TenantInfo;
TenantInfo tenantInfo = new TenantInfo(new HashSet<>(adminRoles),new HashSet<>(allowedClusters));
admin.tenants().createTenant(tenantName, tenantInfo);
Error: Cannot instantiate the type TenantInfo
Try with:
admin.tenants().createTenant(tenantName,
TenantInfo.builder()
.adminRoles(adminRoles)
.allowedClsuters(allowedClusters)
.build());

Django Admin: list_display and ImportExport not working Simultaneosly

I am working on a multi-database Django project with Import Export Function for a database update.
If I place #admin.register before ImportExport List_display does not work
Admin.py
from django.contrib import admin
from .models import *
from import_export.admin import ImportExportModelAdmin
class ViewAdmin(ImportExportModelAdmin):
pass
#admin.register(English,Data1,Data2, Data3, Data4, Data5)
class EnglishAdmin(admin.ModelAdmin):
list_display = ("name","views")
if I use this method I'm not having the Import-export function, But I'm able to use the list_display function
Admin.py
from django.contrib import admin
from .models import *
from import_export.admin import ImportExportModelAdmin
#admin.register(English,Data1,Data2, Data3, Data4, Data5)
class ViewAdmin(ImportExportModelAdmin):
pass
class EnglishAdmin(admin.ModelAdmin):
list_display = ("name","views")
If I use this method I'm not able to use the list_display function, Import export function is working
Is there any way we can Use both Functions ?
You can register English model separately
from django.contrib import admin
from .models import *
from import_export.admin import ImportExportModelAdmin
#admin.register(Data1,Data2, Data3, Data4, Data5)
class ViewAdmin(ImportExportModelAdmin):
pass
#admin.register(English)
class EnglishAdmin(ImportExportModelAdmin):
list_display = ("name","views")
If you have some custom login in ViewAdmin class then EnglishAdmin can inherit from it

Kotlin - menuInflater cannot find reference of the xml file

I am trying to add create option menu to my activity, however the android-studio sent me this error
Unresolved reference: chat_app_menu
Here is my code in Kotlin
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
menuInflater.inflate(R.menu.chat_app_menu)
return true
}
The line with menuInflater.inflate(R.menu.chat_app_menu) show me the error Unresolved reference: chat_app_menu
However, I have been create the resource file chat_app_menu.xml under res\menu\
Here are my import files
package com.example.chat_app
import android.R
import android.os.Bundle
import android.util.Log
import android.view.Menu
import android.view.MenuInflater
import androidx.appcompat.app.AppCompatActivity
import com.google.firebase.auth.FirebaseAuth
My file directory:
What should I do to disable this error to make the app work?
Use your com.example.chat_app.R instead of android.R
import com.example.chat_app.R

Issues using shareplum to access sharepoint

I'm trying to access a sharepoint site using Shareplum.
from shareplum import Site
from shareplum import Office365
authcookie = Office365('https://my.sharepoint.com', username='username#domain.edu', password='password').GetCookies()
site = Site('https://my.sharepoint.com/personal/.../_layouts/15/onedrive.aspx', authcookie=authcookie)
sp_list = site.List('list items')
data = sp_list.GetListItems('All Items', rowlimit=200)
However, I get the following error when I try to run this script.
Exception: ('ERROR:', 500, '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><soap:Fault><faultcode>soap:Server</faultcode><faultstring>Exception of type \'Microsoft.SharePoint.SoapServer.SoapServerException\' was thrown.</faultstring><detail><errorstring xmlns="http://schemas.microsoft.com/sharepoint/soap/">\r\n List does not exist.\r\n The page you selected contains a list that does not exist. It may have been deleted by another user.\r\n </errorstring><errorcode xmlns="http://schemas.microsoft.com/sharepoint/soap/">0x82000006</errorcode></detail></soap:Fault></soap:Body></soap:Envelope>')
Any ideas of what is going on?
The error shows that the specified list does not exist. From the site url, i understand you want to retrieval list items from personal site (onedrive). Please take a reference of below code, it works well here:
from shareplum import Site
from shareplum import Office365
from shareplum.site import Version
from config import config
# get data from configuration
username = config['sp_user']
password = config['sp_password']
authcookie = Office365('https://xxx-my.sharepoint.com', username=username, password=password).GetCookies()
site = Site('https://xxx-my.sharepoint.com/personal/aaa_xxx_onmicrosoft_com',version=Version.v365, authcookie=authcookie)
sp_list = site.List('Documents')
data = sp_list.GetListItems('All',row_limit=10)
print(data)

Resources