2022-04-20

JasperReport, always get blank PDF?

 
line below with new JREmptyDataSource() will get pdf as per expected.

jasperPrint = JasperFillManager.fillReport(report, jrParam, new JREmptyDataSource());



vs

where as using static _DATA_SOURCE_EMPTY, will always get blank pdf.

private static JREmptyDataSource _DATA_SOURCE_EMPTY = new JREmptyDataSource();

...
jasperPrint = JasperFillManager.fillReport(report, jrParam, _DATA_SOURCE_EMPTY);
...










2022-04-14

Multiple JasperPrint into a pdf with output as file and byte[]

 Multiple JasperPrint into a pdf with output as file and byte[]

JasperExportManager.exportReportToPdf vs JRPdfExporter.exportReport()








Found: https://community.jaspersoft.com/questions/526021/how-merge-multiple-pdf-jasper-reports-one







Multiple JasperPrint into a file
setCreatingBatchModeBookmarks

public void pdf() throws JRException { long start = System.currentTimeMillis(); List<JasperPrint> jasperPrintList = new ArrayList<JasperPrint>(); jasperPrintList.add((JasperPrint)JRLoader.loadObjectFromFile("build/reports/Report1.jrprint")); jasperPrintList.add((JasperPrint)JRLoader.loadObjectFromFile("build/reports/Report2.jrprint")); jasperPrintList.add((JasperPrint)JRLoader.loadObjectFromFile("build/reports/Report3.jrprint")); JRPdfExporter exporter = new JRPdfExporter(); exporter.setExporterInput(SimpleExporterInput.getInstance(jasperPrintList)); exporter.setExporterOutput(new SimpleOutputStreamExporterOutput("build/reports/BatchExportReport.pdf")); SimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration(); configuration.setCreatingBatchModeBookmarks(true); exporter.setConfiguration(configuration); exporter.exportReport(); System.err.println("PDF creation time : " + (System.currentTimeMillis() - start)); }



JRPdfExporter to byte array

Found: https://www.tabnine.com/code/java/methods/net.sf.jasperreports.engine.export.JRPdfExporter/setParameter

public byte[] exportToPdf(JasperPrint jasperPrint) throws JRException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); JRPdfExporter exporter = new JRPdfExporter(jasperReportsContext); exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(baos)); exporter.exportReport(); return baos.toByteArray(); }




more Java JRPdfExporter.exportReport方法代碼示例
Found: https://vimsky.com/zh-tw/examples/detail/java-method-net.sf.jasperreports.engine.export.JRPdfExporter.exportReport.html


示例1: export
示例2: savePDFReportToOutputStream
示例3: concatPDFReport
示例4: concatPDFReportEncrypted


Billson: file
示例5: pdf























2022-04-13

Resolved: No qualifying bean of type 'org.springframework.boot.web.client.RestTemplateBuilder'

 
JUnit
TestCase
Spring Boot


Add annotation of 
@AutoConfigureWebClient
to your test case.

org.springframework.boot.test.autoconfigure.web.client.AutoConfigureWebClient



Together with
@ContextConfiguration(classes = {LocalConfig.class})

org.springframework.test.context.ContextConfiguration


public class LocalConfig {

/**
*/
public LocalConfig() {
}
@Bean
public RestTemplate restTemplate(RestTemplateBuilder builder) {
   // Do any additional configuration here
   return builder.build();
}

}


to resolve this.

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.boot.web.client.RestTemplateBuilder' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}






org.springframework.beans.factory.BeanFactory.getBean( ) with args

 


org.springframework.beans.factory.BeanFactory.getBean( ) with args


Source URL: https://www.programcreek.com/java-api-examples/?class=org.springframework.beans.factory.BeanFactory&method=getBean

public static void main(String[] args) {
    // 配置 XML 配置文件
    // 启动 Spring 应用上下文
    BeanFactory beanFactory = new ClassPathXmlApplicationContext("classpath:/META-INF/bean-instantiation-context.xml");
    User user = beanFactory.getBean("user-by-static-method", User.class);
    User userByInstanceMethod = beanFactory.getBean("user-by-instance-method", User.class);
    User userByFactoryBean = beanFactory.getBean("user-by-factory-bean", User.class);
    System.out.println(user);
    System.out.println(userByInstanceMethod);
    System.out.println(userByFactoryBean);

    System.out.println(user == userByInstanceMethod);
    System.out.println(user == userByFactoryBean);

}


Details at:







2022-04-12

@RunWith vs @SpringBootTest

 

https://stackoverflow.com/questions/58901288/springrunner-vs-springboottest







@RunWith(SpringRunner.class) : You need this annotation to just enable spring boot features like @Autowire@MockBean etc.. during junit testing

is used to provide a bridge between Spring Boot test features and JUnit. Whenever we are using any Spring Boot testing features in our JUnit tests, this annotation will be required.

@SpringBootTest : This annotation is used to load complete application context for end to end integration testing

The @SpringBootTest annotation can be used when we need to bootstrap the entire container. The annotation works by creating the ApplicationContext that will be utilized in our tests.

Here is the article with clear examples on both scenarios Baeldung














Resolved: Caused by: java.lang.IllegalStateException: Unable to retrieve @EnableAutoConfiguration base packages

 




Referring to URL below:
https://github.com/spring-projects/spring-boot/issues/10465#issuecomment-336397898
 
Added @AutoConfigurationPackage to avoid error: Caused by: java.lang.IllegalStateException: Unable to retrieve @EnableAutoConfiguration base packages

into the class u made as:
org.springframework.context.annotation.Configuration




Relevant reads:
  1. https://blog.csdn.net/wuqingsssss/article/details/113115809
  2. https://its401.com/article/wuqingsssss/113115809




2022-04-07

Regex to split htop details

 

^( *\d+) (\w+) +(\d+) +(-?\d+) +(\d+.?\d?\w?) +(\w+) +(\w+) +S +(\d+.?\d+) +(\d+.?\d+) +(\d+h?:?\d?\d?:?\.?\d?\d?) +[├│└][\+─ ] (.*)$


2022-04-05

Web characters - emoji

 



Emoji 14.02021-09-14Unicode 14.0E14.0



🌏🗺🧭
🦷
➀➁➂➃➄➅➆➇➈➉
🏀
🎮🕹🎮🕹
🔋

🉑


more at: https://www.w3schools.com/charsets/ref_utf_dingbats.asp




🇲🇾
more at: https://unicode.org/emoji/charts/full-emoji-list.html



Emoji Versions

Emoji VersionDateUnicode VersionData File Comment
N/AvariousvariousE0.0
N/A2010-10-11Unicode 6.0E0.6
N/A2014-06-16Unicode 7.0E0.7
Emoji 1.02015-06-09Unicode 8.0E1.0
Emoji 2.02015-11-12Unicode 8.0E2.0
Emoji 3.02016-06-03Unicode 9.0E3.0
Emoji 4.02016-11-22Unicode 9.0E4.0
Emoji 5.02017-06-20Unicode 10.0E5.0
Emoji 11.02018-05-21Unicode 11.0E11.0
Emoji 12.02019-03-05Unicode 12.0E12.0
Emoji 12.12019-10-21Unicode 12.1E12.1
Emoji 13.02020-03-10Unicode 13.0E13.0
Emoji 13.12020-09-15Unicode 13.0E13.1
Emoji 14.02021-09-14Unicode 14.0E14.0




7 PRINCIPLES OF DATA PROTECTION

 


https://www.pdp.gov.my/jpdpv2/public/principles-of-data-protection/?lang=en

PRINCIPLES OF DATA PROTECTION

Share

Share on facebook
Share on google
Share on twitter

7 PRINCIPLES OF DATA PROTECTION

Reasonably, people should know how we obtained personal data and recognizing the 7 Principles Personal Data Protection prescribed by the PDPA, 2010 (Act 709) ie:-

7 Personal Data Protection Principles which must be adhered to under section 5 (1) of the Act & nbsp; The 709-by maintaining the integrity of personal data :-

  • First – General Principles in which a consumer is not allowed to process personal data of someone else without permission. Understanding the process here should be understood as the control of data through automated means or methods or computing or any other process.
  • Second – must comply with the Principles of Notice and Choice in which information and destination prefix notified to data subjects concerned.
  • Third – Disclosure Principle destination is a subject of personal data in order to identify the purposes for which personal data are to be disclosed.
  • Fourth – Principles of Safety & ndash; when processing personal data any subject, taking steps to keep the data safe, non-modified, misused or given to the parties that do not concerned.
  • Fifth – Retention Principle: The personal data shall not be kept in any processing over the time limit required.
  • Sixth – Data Integrity Principle & ndash; any personal data ascertained so accurate, complete, not misleading and meets the intent of the latest data is stored and processed.
  • Seventh – Access Principle: a person shall be entitled to access personal data held by a data user and also can correct it in order to update its data.

Therefore Malaysians in particular should be aware of their rights according to the principles contained in the Act.







Google Referrals