use of com.liferay.ide.kaleo.core.model.Assignable in project liferay-ide by liferay.
the class CurrentAssignmentsDerviedValueService method compute.
@Override
protected String compute() {
StringBuilder data = new StringBuilder();
Assignable assignable = context(Assignable.class);
ElementHandle<User> assignableUser = assignable.getUser();
User user = assignableUser.content(false);
ElementList<Role> roles = assignable.getRoles();
ElementHandle<Scriptable> scripteAssignment = assignable.getScriptedAssignment();
Scriptable scriptable = scripteAssignment.content(false);
ElementList<ResourceAction> resourceActions = assignable.getResourceActions();
if (user != null) {
Value<Integer> userId = user.getUserId();
Value<String> userScreenName = user.getScreenName();
Value<String> userEmailAddress = user.getEmailAddress();
if (userId.content() != null) {
data.append(userId.content() + ", ");
} else if (userScreenName.content() != null) {
data.append(userScreenName.content() + ", ");
} else if (userEmailAddress.content() != null) {
data.append(userEmailAddress.content() + ", ");
} else {
data.append("User: Asset Creator");
}
}
if (ListUtil.isNotEmpty(roles)) {
data.append("Roles: ");
for (Role role : roles) {
Value<Integer> roleId = role.getRoleId();
Value<String> roleName = role.getName();
if (roleId.content() != null) {
data.append(roleId.content() + ", ");
} else {
data.append(roleName.text() + ", ");
}
}
}
if (scriptable != null) {
Value<String> script = scriptable.getScript();
Value<ScriptLanguageType> scriptLanguageType = scriptable.getScriptLanguage();
if (script.content() != null) {
data.append("Script language: " + scriptLanguageType.content());
}
}
if (ListUtil.isNotEmpty(resourceActions)) {
data.append("Resource actions: ");
for (ResourceAction resourceAction : resourceActions) {
Value<String> reAction = resourceAction.getResourceAction();
if (reAction.content() != null) {
data.append(reAction.content() + ", ");
}
}
}
String dataInfo = data.toString();
return dataInfo.replaceAll(", $", "");
}
Aggregations