Jump to content
We've recently updated our Privacy Statement, available here ×

kkumlien

Members
  • Posts

    137
  • Joined

  • Last visited

 Content Type 

Profiles

Forum

Events

Featured Visualizations

Knowledge Base

Documentation (PDF Downloads)

Blog

Documentation (Test Area)

Documentation

Dr. Jaspersoft Webinar Series

Downloads

Everything posted by kkumlien

  1. Hi Jigar, the $P! syntax should work. Can you compile and display a report in iReport or Jaspersoft Studio? Once that works, then if you don't manage to publish it to JasperReports Server please create a new question about that and let us know here. Thanks!
  2. Hi Urvashi, why are you using two Detail bands? Unless you want to print the tables for each row in the Detail band, then I'd suggest moving both of them to the Title or Summary band. Then remove the Details bands if not required. Kind regards
  3. Hi Urvashi, I recommend two things to increase the chance of someone replying to your questions: 1. use a spell checker, 2. do not write the whole question in the summary but put it in the description ; ) Thanks!
  4. Hi Angel, one way to do that is populating Variables in a report with values from the database, then using those Variables to fill the Parameters of a subreport within the same report. Let me know if this helps and if so, please up-vote the answer. Thanks!
  5. Hi aavhad, can you please provide a link to a sample SQLite database (with anonymized data) so that I can test it, or edit the original question and add it as attachment? What version of iReport are you using?
  6. @kxchong647 If the other payment is also not printed it there might be other rows with $1000 before that? What version of iReport are you using?
  7. Hi Marita, you can easily add an hyperlink for each row in the report, e.g. using unique / primary key column(s) from your SQL Server table, such as your documents' ID. To produce a URL such as (for example) http://example.com/document-download.php?id=35 , you could use an expression (also here) such as: "http://example.com/document-download.php?id=" + $F{document_id} That is assuming your field is named "document_id" in the report. Of course all of this would only work if you can create a web application (for example PHP as per my example above) that would serve you the file from the database via HTTP. In theory you could also do that via JasperReports Server but that would add unnecessary complexity. See a sample PHP application here: http://stackoverflow.com/questions/10616302/mssql-varbinary-to-pdf-using-php I'm sure you can find similar examples for other programming languages if you need. Kind regards
  8. Hi Hozawa, thanks for sharing! Please let me know if you'd like to share your code via the Exchange and I should be able to help you. P.s. For your next video I'd suggest setting the UI locale to English so that more people will be able to understand ; )
  9. Hi Omorak, Crosstabs create rows and columns based on the data. Ideally you would prepare your data so that you can do the minimum amount of effort in the report, e.g. via Jaspersoft ETL. A standard Table might suit you better if you want a predetermined design (although you'd have to calculate aggregated values via Variables, etc.). In alternative you could create a database table with all the months in your Data Source and UNION it with your actual data. This would guarantee that at least one row is returned for each month. See this example (only for 3 months): foodmart=# CREATE TABLE sales_months (month_id INT, month VARCHAR);CREATE TABLEfoodmart=# CREATE TABLE sales (location VARCHAR, month_id INT, amount INT);CREATE TABLEfoodmart=#foodmart=# INSERT INTO sales_months VALUES (1, 'jan');INSERT 0 1foodmart=# INSERT INTO sales_months VALUES (2, 'feb');INSERT 0 1foodmart=# INSERT INTO sales_months VALUES (3, 'mar');INSERT 0 1foodmart=# INSERT INTO sales VALUES ('london', 1, 500);INSERT 0 1foodmart=# INSERT INTO sales VALUES ('london', 3, 200);INSERT 0 1foodmart=# INSERT INTO sales VALUES ('paris', 1, 50);INSERT 0 1foodmart=#foodmart=# SELECT NULL AS location, month_id, month, NULL AS amount FROM sales_monthsfoodmart-# UNION ALLfoodmart-# (SELECT s.location, s.month_id, sm.month, s.amount FROM sales sfoodmart(# JOIN sales_months sm ON s.month_id = sm.month_idfoodmart(# ORDER BY s.location, s.month_id);location | month_id | month | amount----------+----------+-------+-------- | 1 | jan | | 2 | feb | | 3 | mar | london | 1 | jan | 500 london | 3 | mar | 200 paris | 1 | jan | 50Unfortunately this also creates an empty row in the Crosstab, which I "hid" via "Print When Expression" equal to "$V{location1} != null", "Remove Line When Blank" and "Blank When NULL" on all the elements of the row, but it stil leaves an empty space which I've been unable to remove. I also enabled the "Data Pre Sorted" flag in the Crosstab Dataset properties. This will not occur if you use a value that you know is always returned by your query, e.g. location 'paris'. Then you would use SELECT 'paris' AS location at the beginning of the query above. This is the end result:
  10. http://community.jaspersoft.com/wiki/conditional-display-column-based-its-data
  11. Ciao Marco, 3.6.0 is very old, I guess you refer to 5.6.0 which is the last release and available here: http://community.jaspersoft.com/project/ireport-designer/releases Please note that iReport is no longer maintained, we recommend to use Jaspersoft Studio: http://community.jaspersoft.com/project/jaspersoft-studio If you'd like to purchase a license to use Professional features such as HTML5 Charts and Charts Pro, please contact us here: http://www.jaspersoft.com/contact-us Kind regards
  12. Hi Craig, this article might have the answer: http://community.jaspersoft.com/wiki/report-zoom-visualizejs Please let me know if that doesn't work for you. Cheers
  13. IntroductionAs documented in Creating a Custom Processor, JasperReports Server allows to "create custom code to run on the server after the user has been authenticated". Here we show sample code that adds the following features to the externalUserFolderProcessor (which is already provided as an example in the documentation): Configurable permissions by folder owner and rolesConfigurable label and resource ID for the folderPossibility to create the parent folder automaticallyYou can use the sample code to build your own library as a JAR file and add it to your server. It is recommended to replace the level sample in the package name hierarchy with something else specific to your project or company name. This code has been tested on the latest release of the Professional edition of JasperReports Server, which is 6.1.1 at the time of writing. It is likely to work on the Community edition from release 6.0.1. Please be aware that this sample code is provided AS IS, it is your responsibility to review it and make sure it satisfies your requirements. Feel free to modify it and adapt it to your needs. Update 2020-06-12 – see also an example of Token-based / Pre-Authenticated SSO that can provide some of the Org / User properties that can be used by the custom folder processor: https://community.jaspersoft.com/wiki/adding-email-address-and-other-properties-users-sso-customizations Sample codeJasperServerPermissionUtilThis class is useful to check if a JRS Repository permission is valid. package com.jaspersoft.jasperserver.api.security.externalAuth.sample.processors;import com.jaspersoft.jasperserver.api.metadata.security.JasperServerPermission;/** * This class is useful to check if a JRS Repository permission is valid. * */public class JasperServerPermissionUtil { // Array required by the abstract superclass via getValidPermissions() private static final int[] VALID_PERMISSIONS = { JasperServerPermission.NOTHING.getMask(), JasperServerPermission.ADMINISTRATION.getMask(), JasperServerPermission.READ.getMask(), JasperServerPermission.WRITE.getMask(), JasperServerPermission.CREATE.getMask(), JasperServerPermission.DELETE.getMask(), JasperServerPermission.READ_WRITE_CREATE_DELETE.getMask(), JasperServerPermission.READ_WRITE_CREATE.getMask(), JasperServerPermission.READ_WRITE.getMask(), JasperServerPermission.READ_WRITE_DELETE.getMask(), JasperServerPermission.EXECUTE.getMask() }; private static final String[] VALID_PERMISSIONS_AS_STRING = { "NOTHING", "ADMINISTRATION", "READ", "WRITE", "CREATE", "DELETE", "READ_WRITE_CREATE_DELETE", "READ_WRITE_CREATE", "READ_WRITE", "READ_WRITE_DELETE", "EXECUTE" }; /** * Parse a permission {@link String} literal and return associated value. * * @param permission one of the field names that represent a permission: ADMINISTRATION, * READ, WRITE,... * @return the value associated to that permission * @throws IllegalArgumentException if argument is not a valid permission */ public static int parsePermission(String permission) { for (int i = 0; i < VALID_PERMISSIONS_AS_STRING.length; i++) { if (VALID_PERMISSIONS_AS_STRING[i].equalsIgnoreCase(permission)) { return VALID_PERMISSIONS[i]; } } throw new IllegalArgumentException("Permission provided does not exist: " + permission); }}[/code] FolderHelper This class is useful to handle folders in the JRS Repository. package com.jaspersoft.jasperserver.api.security.externalAuth.sample.processors;import java.util.ArrayList;import java.util.List;import java.util.regex.Pattern;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import org.springframework.security.core.context.SecurityContextHolder;import com.jaspersoft.jasperserver.api.common.domain.ExecutionContext;import com.jaspersoft.jasperserver.api.common.domain.impl.ExecutionContextImpl;import com.jaspersoft.jasperserver.api.metadata.common.domain.Folder;import com.jaspersoft.jasperserver.api.metadata.common.domain.InternalURI;import com.jaspersoft.jasperserver.api.metadata.common.domain.client.FolderImpl;import com.jaspersoft.jasperserver.api.metadata.common.service.RepositoryService;import com.jaspersoft.jasperserver.api.metadata.user.domain.ObjectPermission;import com.jaspersoft.jasperserver.api.metadata.user.domain.Role;import com.jaspersoft.jasperserver.api.metadata.user.domain.User;import com.jaspersoft.jasperserver.api.metadata.user.service.ObjectPermissionService;import com.jaspersoft.jasperserver.api.metadata.user.service.UserAuthorityService;/** * This class is useful to handle folders in the JRS Repository. * */public class FolderHelper { private static Log log = LogFactory.getLog(FolderHelper.class); private RepositoryService repositoryService; private ObjectPermissionService permissionService; private ExecutionContext ctx; private UserAuthorityService internalUserAuthorityService; protected static final Pattern RESOURCE_ID_INVALID_CHAR = Pattern.compile("[^\p{L}\p{N}]"); protected static final String RESOURCE_ID_CHAR_REPLACEMENT = "_"; /** * Constructor for the Folder Helper Class * @param repositoryService * @param permissionService * @param internalUserAuthorityService */ public FolderHelper(RepositoryService repositoryService, ObjectPermissionService permissionService, UserAuthorityService internalUserAuthorityService) { super(); this.repositoryService = repositoryService; this.permissionService = permissionService; this.internalUserAuthorityService = internalUserAuthorityService; this.ctx = getAdminContext(); } /** * Set a Permission to a folder for the requested role * @param target The InternalURI of the folder * @param role The role expressed as String * @param permissionType Permission type expressed as String, the available values are available in the class JasperServerAclEntry * @return the object permission generated, already saved using the permissionService */ public ObjectPermission setPermissionOnFolderForRole(InternalURI target, String role, String permissionType) { Role userRole=internalUserAuthorityService.getRole(ctx, role); return setPermissionsToFolder(target, userRole, permissionType); } /** * Set a Permission to a folder for the requested user * @param target The InternalURI of the folder * @param user The role expressed as String * @param permissionType Permission type expressed as String, the available values are available in the class JasperServerAclEntry * @return the object permission generated, already saved using the permissionService */ public ObjectPermission setPermissionOnFolderForUser(InternalURI target, User user, String permissionType) { return setPermissionsToFolder(target, user, permissionType); } /** * Set a Permission to a folder for the requested recipient * @param target The InternalURI of the folder * @param recipient The recipient of the permission, it can be a User, a Role... * @param permissionType Permission type expressed as String, the available values are available in the class JasperServerAclEntry * @return the object permission generated, already saved using the permissionService */ public ObjectPermission setPermissionsToFolder(InternalURI target, Object recipient, String permissionType) { int permissionMask = JasperServerPermissionUtil.parsePermission(permissionType); ObjectPermission permission = permissionService.newObjectPermission(ctx); permission.setURI(target.getURI()); permission.setPermissionRecipient(recipient); permission.setPermissionMask(permissionMask); permissionService.putObjectPermission(ctx, permission); return permission; } /** * Create a new folder * @param name Name of the folder * @param label Label of the folder * @param parent parent URI for the folder * @param description Description of the folder * @return the Folder Object for the created folder */ public Folder createFolder(String name, String label, String parent, String description) { Folder folder = new FolderImpl(); folder.setName(name); folder.setLabel(label); folder.setParentFolder(parent); folder.setDescription(description); repositoryService.saveFolder(ctx, folder); return folder; } public String createFolderIfNotExists(String name, String label, String parent, String description) { String folderPath = parent + Folder.SEPARATOR + name; if(!folderExists(folderPath)){ createFolder(name, label, parent, description); } return folderPath; } /** * Remove all the setted up permissions on a folder. * It retrieves only the permissions defined for the folder, not the inherited ones. * An inherited permission is marked with a * in the JRS interfaces * @param folder */ public void removeAllPermissionsFromFolder(InternalURI folder){ User currentUser = (User)SecurityContextHolder.getContext().getAuthentication().getPrincipal(); List listPermissions=permissionService.getEffectivePermissionsForObject(ctx, folder); for(ObjectPermission perm:listPermissions){ log.error("deleting permission for:"+perm.getPermissionRecipient().toString()); if(!perm.getPermissionRecipient().equals(currentUser)){ int permissionMask = JasperServerPermissionUtil.parsePermission("NOTHING"); perm.setPermissionMask(permissionMask); permissionService.putObjectPermission(ctx, perm); } } } /** * @return the AdminContext, needed to perform some operations on folders */ protected ExecutionContext getAdminContext() { ExecutionContext ctx = new ExecutionContextImpl(); List attrs = new ArrayList(); attrs.add(ObjectPermissionService.PRIVILEGED_OPERATION); ctx.setAttributes(attrs); return ctx; } /** * @param folderPath * @return true if the folder already exists in the repository */ public boolean folderExists(String folderPath){ return repositoryService.getFolder(ctx, folderPath)!=null; } /** * @param inputLabel the name to set as ID * @return the String with unallowed character replaced by _ */ public static String getCompliantIdForResource(String inputLabel){ String id = RESOURCE_ID_INVALID_CHAR.matcher(inputLabel).replaceAll( RESOURCE_ID_CHAR_REPLACEMENT); return id; }}[/code] ExtendedUserFolderProcessor This class is useful to create a folder automatically when a user logs in and set its permissions according to configuration. It adds features to externalUserFolderProcessor (which is already provided as an example in the documentation). package com.jaspersoft.jasperserver.api.security.externalAuth.sample.processors;import java.util.Collections;import java.util.Map;import org.apache.log4j.LogManager;import org.apache.log4j.Logger;import org.springframework.security.core.context.SecurityContextHolder;import com.jaspersoft.jasperserver.api.metadata.common.domain.Folder;import com.jaspersoft.jasperserver.api.metadata.common.util.RepositoryLabelIDHelper;import com.jaspersoft.jasperserver.api.metadata.user.domain.User;import com.jaspersoft.jasperserver.api.security.externalAuth.processors.AbstractExternalUserProcessor;/** * This class is useful to create a folder automatically when a user logs in and set * its permissions according to configuration. * It adds features to externalUserFolderProcessor (which is already provided as an example in * the documentation). * */public class ExtendedUserFolderProcessor extends AbstractExternalUserProcessor { private static final Logger log = LogManager.getLogger(ExtendedUserFolderProcessor.class); // The parent folder to create user directories under. default value is root. private String userFoldersParentDirectory = ""; // The permission for the home folder created private String userPermissionOnFolder = "READ_WRITE_CREATE_DELETE"; // Map containing ROLE_NAME : permission_on_folder private Map rolePermissionMap = Collections.emptyMap(); // Pattern for the folder label private String folderLabelPattern = UserDetailPropertyKey.USERNAME.value; // Pattern for the folder id private String folderIdPattern = UserDetailPropertyKey.USERNAME.value; private Boolean createParentFolder = Boolean.FALSE; // Checks if user has a folder on his name in the configured location, if not creates // one. The parent folder is created if not existent and requested. @Override public void process() { FolderHelper helper = new FolderHelper(getRepositoryService(), getObjectPermissionService(), getUserAuthorityService()); if (getCreateParentFolder()&&!helper.folderExists(getUserFoldersParentDirectory())){ createParentFolder(helper); } if (!helper.folderExists(getUserFolderPathUri())){ createUserFolder(helper); } } private void createUserFolder(FolderHelper helper) { User currentUser = (User)SecurityContextHolder.getContext().getAuthentication().getPrincipal(); // preparing the folder String folderLabel = getUserFolderLabel(currentUser); String generatedId = RepositoryLabelIDHelper.generateIdBasedOnLabel(getRepositoryService(), getUserFolderPathUri(), getUserFolderId(currentUser)); Folder folder = helper.createFolder(generatedId, folderLabel, getUserFoldersParentDirectory(), "Default user folder"); log.debug("folder "+folder.getName()+" was created with label ""+folder.getLabel()+"" ."); // setting the permission for the user helper.setPermissionsToFolder(folder, currentUser, getUserPermissionOnFolder()); for(String role : getRolePermissionMap().keySet()){ String permissionType = getRolePermissionMap().get(role); helper.setPermissionOnFolderForRole(folder, role, permissionType); } } private void createParentFolder(FolderHelper helper) { // Preparing the folder Integer lastIdx = getUserFoldersParentDirectory().lastIndexOf(Folder.SEPARATOR); String dirName = getUserFoldersParentDirectory().substring(lastIdx+1); String dirParentPath = getUserFoldersParentDirectory().substring(0, lastIdx); String generatedId = RepositoryLabelIDHelper.generateIdBasedOnLabel(getRepositoryService(), dirParentPath, dirName); Folder folder = helper.createFolder(generatedId, dirName, dirParentPath, "Container for user folders"); log.debug("folder "+folder.getName()+" was created with label ""+folder.getLabel()+"" ."); } private String getStringFromPattern(User currentUser, String folderId) { String folderLabel = folderId; folderLabel = folderLabel.replaceAll(UserDetailPropertyKey.USERNAME.value, currentUser.getUsername()); folderLabel = folderLabel.replaceAll(UserDetailPropertyKey.FULL_NAME.value, currentUser.getFullName()); folderLabel = folderLabel.replaceAll(UserDetailPropertyKey.EMAIL_ADDRESS.value, currentUser.getEmailAddress()); folderLabel = folderLabel.replaceAll(UserDetailPropertyKey.TENANT.value, currentUser.getTenantId()); return folderLabel; } private String getUserFolderId(User currentUser) { return getStringFromPattern(currentUser, getFolderIdPattern()); } private String getUserFolderLabel(User currentUser) { return getStringFromPattern(currentUser, getFolderLabelPattern()); } private String getUserFolderPathUri() { User user = ((User)SecurityContextHolder.getContext().getAuthentication().getPrincipal()); String folderId = getUserFolderId(user); return getUserFoldersParentDirectory() + Folder.SEPARATOR + FolderHelper.getCompliantIdForResource(folderId); } public String getUserFoldersParentDirectory() { return userFoldersParentDirectory; } public void setUserFoldersParentDirectory(String userFoldersParentDirectory) { this.userFoldersParentDirectory = userFoldersParentDirectory; } public Map getRolePermissionMap() { return rolePermissionMap; } public void setRolePermissionMap(Map rolePermissionMap) { this.rolePermissionMap = rolePermissionMap; } public String getUserPermissionOnFolder() { return userPermissionOnFolder; } public void setUserPermissionOnFolder(String userPermissionOnFolder) { this.userPermissionOnFolder = userPermissionOnFolder; } public String getFolderLabelPattern() { return folderLabelPattern; } public void setFolderLabelPattern(String folderLabelPattern) { this.folderLabelPattern = folderLabelPattern; } public String getFolderIdPattern() { return folderIdPattern; } public void setFolderIdPattern(String folderIdPattern) { this.folderIdPattern = folderIdPattern; } public Boolean getCreateParentFolder() { return createParentFolder; } public void setCreateParentFolder(Boolean createParentFolder) { this.createParentFolder = createParentFolder; } private enum UserDetailPropertyKey{ USERNAME("USERNAME"), FULL_NAME("FULL_NAME"),EMAIL_ADDRESS("EMAIL_ADDRESS"),TENANT("TENANT"); private String value; private UserDetailPropertyKey(String value) { this.value = value; } }}[/code] Configuration Below you can find a sample configuration that could merged into your external authentication XML file, such as applicationContext-externalAuth-preAuth[-mt].xml (the part [-mt] is optional and depends on the edition of JasperReports Server). [...] [/code]
  14. The Sample DB available in Jaspersoft Studio used to be available here: http://anonsvn:anonsvn@code.jaspersoft.com/svn/repos/jasperreports/trunk/jasperreports/demo/hsqldb/ The repo was then moved to GitHub: https://github.com/TIBCOSoftware/jasperreports/tree/master/jasperreports/demo/hsqldb The file test.script can be run on any SQL database with minimal modification.
  15. Hi laceja, as there is no obvious information to figure out what the issue might be, please create a new bug report at http://community.jaspersoft.com/bug-tracker. Please make sure you indicate your Java version there. Ideally, please post the bug number / link as a comment to my answer here. Also please mark the answer as correct or helpful if you think it is so. Thanks!
  16. Hi laceja, you're more likely to get an answer if you edit your original question to provide further information, such as: What steps did you follow to install?What java version are you running (java -version)?What error is reported on screen or log file? (Screenshots or even better copy & paste the stack trace)Unless something obvious comes up, you will probably need to create a new bug report at http://community.jaspersoft.com/bug-tracker Kind regards
  17. Have you tried to set the logging for com.jaspersoft.jasperserver.api.metadata.user.domain.* to DEBUG level? Or maybe a more specific class in that package or in another within the same hierarchy? There are probably other classes that will be useful to expose, but I'm not sure.
  18. It would be interesting to know what is featured in the password used to reset. Is that a previous password, random characters or some well defined word related to the superuser? That might give an indication as to where it's coming from.
  19. ProblemIt may not be user-friendly to display a column in a Table object even though all its values are NULL. SolutionThis video how-to shows basic concepts around conditional display of a column in a Table object, based on its data.This example is based on TIBCO Jaspersoft® Studio 6.0.1 but it should work (possibly with little editing) on previous releases, such as 5.x.
  20. Changed Reproducibility from Not Attempted to Always System Message
×
×
  • Create New...