Ir al contenido
Otras versiones

Cargando…

OKMReport

Esta página aún no está disponible en tu idioma.

You can set several report formats based on the document MIME type:

Description:

Method Return values Description
list(String token, boolean active) List Returns a list of reports.
  • When the variable active is set to true, only the active reports will be returned; otherwise, all reports will be returned.

Example:

package com.openkm;
import com.openkm.api.OKMReport;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMReport okmReport = ContextWrapper.getContext().getBean(OKMReport.class);
System.out.println(okmReport.list(null, true));
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
get(String token, long rpId) Report Returns a Report object.
  • The variable rpId is a long value used to identify the report.

Example:

package com.openkm;
import com.openkm.api.OKMReport;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMReport okmReport = ContextWrapper.getContext().getBean(OKMReport.class);
System.out.println(okmReport.get(null, 1));
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
execute(String token, long rpId, Map<String, Object> params, String format) InputStream Returns the InputStream of the report.
  • The variable rpId is a long value used to identify the report.

Example:

package com.openkm;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;
import com.openkm.api.OKMReport;
import com.openkm.bean.Report;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMReport okmReport = ContextWrapper.getContext().getBean(OKMReport.class);
Calendar yesterday = Calendar.getInstance();
yesterday.add(Calendar.DATE, -1);
Calendar today = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Map<String, Object> params = new HashMap<>(); // report parameters
params.put("from_date", sdf.format(yesterday.getTime()));
params.put("to_date", sdf.format(today.getTime()));
InputStream is = okmReport.execute(null, 1, params, Report.FORMAT_PDF);
} catch (Exception e) {
e.printStackTrace();
}
}
}