Java Code Examples for com.jamonapi.Monitor#stop()

The following examples show how to use com.jamonapi.Monitor#stop() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractSvgViewerEngineResource.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
public EngineStartServletIOManager getIOManager() {
	Monitor getIOManagerMonitor = MonitorFactory.start("GeoEngine.AbstractSvgViewerEngineResource.getIOManager");

	EngineStartServletIOManager ioManager = null;

	try {
		ioManager = new EngineStartServletIOManager(request, response);
		UserProfile userProfile = (UserProfile) ioManager.getParameterFromSession(IEngUserProfile.ENG_USER_PROFILE);
		if (userProfile == null) {
			String userId = request.getHeader("user");
			userProfile = (UserProfile) UserUtilities.getUserProfile(userId);
			ioManager.setUserProfile(userProfile);
		}
	} catch (Exception e) {
		throw new RuntimeException("An unexpected error occured while inizializing ioManager", e);
	}
	getIOManagerMonitor.stop();

	return ioManager;
}
 
Example 2
Source File: SbiDocumentServiceImpl.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
public String getDocumentAnalyticalDriversJSON(String token, String user, Integer id, String language, String country){
	logger.debug("IN");
	Monitor monitor = MonitorFactory.start("spagobi.service.sbidocument.getDocumentParametersJSON");
	try {
	    validateTicket(token, user);
	    this.setTenantByUserId(user);
	    return supplier.getDocumentAnalyticalDriversJSON(id, language, country);
	} catch (SecurityException e) {
	    logger.error("SecurityException", e);
	    return null;
	} finally {
		this.unsetTenant();
	    monitor.stop();
	    logger.debug("OUT");
	}	
}
 
Example 3
Source File: SbiDocumentServiceImpl.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
public SpagobiAnalyticalDriver[] getDocumentAnalyticalDrivers(String token, String user, Integer id, String language, String country){
	logger.debug("IN");
	Monitor monitor = MonitorFactory.start("spagobi.service.sbidocument.getDocumentParameters");
	try {
	    validateTicket(token, user);
	    this.setTenantByUserId(user);
	    return supplier.getDocumentAnalyticalDrivers(id, language, country);
	} catch (SecurityException e) {
	    logger.error("SecurityException", e);
	    return null;
	} finally {
		this.unsetTenant();
	    monitor.stop();
	    logger.debug("OUT");
	}	
}
 
Example 4
Source File: ObjectsAccessVerifier.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * returns the list of correct roles of the input profile for the execution of the document with the specified input
 *
 * @param objectId
 *            the document id
 * @param profile
 *            the user profile
 * @return the list of correct roles of the input profile for the execution of the document with the specified input
 * @throws EMFUserError
 * @throws EMFInternalError
 */
public static List getCorrectRolesForExecution(Integer objectId, IEngUserProfile profile) throws EMFInternalError, EMFUserError {
	Monitor monitor = MonitorFactory.start("spagobi.core.ObjectAccessVerifier.getCorrectRolesForExecution");
	logger.debug("IN");
	List correctRoles = null;
	if (profile.isAbleToExecuteAction(SpagoBIConstants.DOCUMENT_MANAGEMENT_DEV) || profile.isAbleToExecuteAction(SpagoBIConstants.DOCUMENT_MANAGEMENT_USER)
			|| profile.isAbleToExecuteAction(SpagoBIConstants.DOCUMENT_MANAGEMENT_ADMIN)) {
		logger.debug("User is able to execute action");
		correctRoles = DAOFactory.getBIObjectDAO().getCorrectRolesForExecution(objectId, profile);
	} else {
		logger.debug("User is NOT able to execute action");
		correctRoles = DAOFactory.getBIObjectDAO().getCorrectRolesForExecution(objectId);
	}
	logger.debug("OUT");
	monitor.stop();
	return correctRoles;
}
 
Example 5
Source File: DefaultScrollableDataResult.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
public SourceBean getSourceBean() throws EMFInternalError {
	Monitor monitor = MonitorFactory.start("model.data-access.default-scrollable-data-result.get-source-bean");
	try {
		int currentPosition = _rs.getRow();
		moveTo(1);
		SourceBean rowsSourceBean = new SourceBean(ScrollableDataResult.ROWS_TAG);
		DataRow dr = null;
		SourceBean dataRowSourceBean = null;
		int rowsNumber = this.getRowsNumber();
		for (int i = 1; i <= rowsNumber; i++) {
			dr = getDataRow(i);
			dataRowSourceBean = dr.getSourceBean();
			rowsSourceBean.setAttribute(dataRowSourceBean);
		} // for (int i = 1; i <= rowsNumber; i++)
		moveTo(currentPosition);
		return rowsSourceBean;
	} // try
	catch (Exception ex) {
		throw Utils.generateInternalError(ex, "DefaultScrollableDataResult::getSourceBean: ");
	} // catch (SourceBeanException sbe)
	finally {
		monitor.stop();
	} // finally
}
 
Example 6
Source File: ContentServiceImpl.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Read sub object content.
 * 
 * @param token
 *            the token
 * @param user
 *            the user
 * @param subObjectId
 *            the sub object id
 * 
 * @return the content
 */
public Content readSubObjectContent(String token, String user,
		String subObjectId) {
	logger.debug("IN");
	Monitor monitor = MonitorFactory
			.start("spagobi.service.content.readSubObjectContent");
	try {
		validateTicket(token, user);
		this.setTenantByUserId(user);
		return readSubObjectContent(user, subObjectId);
	} catch (SecurityException e) {
		logger.error("SecurityException", e);
		return null;
	} finally {
		this.unsetTenant();
		monitor.stop();
		logger.debug("OUT");
	}

}
 
Example 7
Source File: MapCatalogueImpl.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
    * Map catalogue.
    * 
    * @param token the token
    * @param user the user
    * @param operation the operation
    * @param path the path
    * @param featureName the feature name
    * @param mapName the map name
    * 
    * @return the string
    */
   public String mapCatalogue(String token, String user, String operation,String path,String featureName,String mapName) {

logger.debug("IN");
Monitor monitor =MonitorFactory.start("spagobi.service.content.mapCatalogue");
try {
    validateTicket(token, user);
    this.setTenantByUserId(user);
    return mapCatalogue(user, operation, path, featureName, mapName);
} catch (SecurityException e) {
    logger.error("SecurityException", e);
    return null;
} finally {
	this.unsetTenant();
    monitor.stop();
    logger.debug("OUT");
}	

   }
 
Example 8
Source File: SchedulerServiceImpl.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Delete schedulation.
 * 
 * @param token
 *            the token
 * @param user
 *            the user
 * @param triggerName
 *            the trigger name
 * @param triggerGroup
 *            the trigger group
 * 
 * @return the string
 */
public String deleteSchedulation(String token, String user,
		String triggerName, String triggerGroup) {
	logger.debug("IN");
	Monitor monitor = MonitorFactory
			.start("spagobi.service.scheduler.deleteSchedulation");
	try {
		validateTicket(token, user);
		this.setTenantByUserId(user);
		return supplier.deleteSchedulation(triggerName, triggerGroup);
	} catch (SecurityException e) {
		logger.error("SecurityException", e);
		return null;
	} finally {
		this.unsetTenant();
		monitor.stop();
		logger.debug("OUT");
	}

}
 
Example 9
Source File: DocumentExecutionUtils.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
public static List handleNormalExecutionError(UserProfile profile, BIObject obj, HttpServletRequest req, String env, String role, String modality,
		JSONObject parametersJson, Locale locale) { // isFromCross,
	Monitor handleNormalExecutionErrorMonitor = MonitorFactory.start("Knowage.DocumentExecutionResource.handleNormalExecutionError");

	HashMap<String, String> logParam = new HashMap<String, String>();
	logParam.put("NAME", obj.getName());
	logParam.put("ENGINE", obj.getEngine().getName());
	logParam.put("PARAMS", parametersJson.toString()); // this.getAttributeAsString(PARAMETERS)
	DocumentRuntime dum = new DocumentRuntime(profile, locale);
	DriversValidationAPI validation = new DriversValidationAPI(profile, locale);
	List errors = null;
	try {
		errors = validation.getParametersErrors(obj, role, dum);

	} catch (Exception e) {
		logger.debug("Error in handleNormalExecutionError", e);
		throw new SpagoBIServiceException(SERVICE_NAME, "Cannot evaluate errors on parameters validation", e);

	} finally {
		handleNormalExecutionErrorMonitor.stop();
	}
	return errors;
}
 
Example 10
Source File: JDBCDataProxy.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public ResultSet getData(IDataReader dataReader, Object... resources) {
	logger.debug("IN");
	Statement stmt = (Statement) resources[0];
	ResultSet resultSet = null;
	try {
		if (getMaxResults() > 0) {
			stmt.setMaxRows(getMaxResults());
		}
		String sqlQuery = getStatement();
		LogMF.info(logger, "Executing query:\n{0}", sqlQuery);
		Monitor timeToExecuteStatement = MonitorFactory.start("Knowage.JDBCDataProxy.executeStatement:" + sqlQuery);
		try {
			resultSet = stmt.executeQuery(sqlQuery);
		} finally {
			timeToExecuteStatement.stop();
		}
		LogMF.debug(logger, "Executed query:\n{0}", sqlQuery);
		return resultSet;
	} catch (SQLException e) {
		throw new SpagoBIRuntimeException(e);
	} finally {
		logger.debug("OUT");
	}
}
 
Example 11
Source File: SPARQLDataProxy.java    From Knowage-Server with GNU Affero General Public License v3.0 5 votes vote down vote up
private ResultSet executeSPARQLQuery(QueryExecution queryExecution) {
	queryExecution.setTimeout(executionTimeout * 1000);
	Monitor monitor = MonitorFactory.start("Knowage.SPARQLDataProxy.executeSPARQLQuery");
	ResultSet resultSet = null;
	try {
		resultSet = queryExecution.execSelect();
	} finally {
		monitor.stop();
	}
	return resultSet;
}
 
Example 12
Source File: SbiMetaSourceDAOHibImpl.java    From Knowage-Server with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public List<SbiMetaTable> loadMetaTables(Session aSession, Integer sourceId) throws EMFUserError {
	Monitor monitorGeneral = MonitorFactory.start("metasource.dao.loadMetaTables.business.all");
	LogMF.debug(logger, "IN: id = [{0}]", sourceId);

	List<SbiMetaTable> toReturn = new ArrayList<SbiMetaTable>();
	Session session = aSession;

	try {
		if (sourceId == null) {
			throw new IllegalArgumentException("Input parameter [sourceId] cannot be null");
		}

		Query query = session.createQuery(" from SbiMetaTable smt where smt.sbiMetaSource.sourceId = ? ");
		query.setInteger(0, sourceId);
		List<SbiMetaTable> list = query.list();
		Iterator<SbiMetaTable> it = list.iterator();
		while (it.hasNext()) {
			toReturn.add(toMetaTable(it.next()));
		}
		logger.debug("Contents loaded");

	} catch (Throwable t) {
		logException(t);

		throw new SpagoBIDAOException("An unexpected error occured while loading meta tables of meta source with sourceId [" + sourceId + "]", t);
	} finally {
		monitorGeneral.stop();
		LogMF.debug(logger, "OUT: returning [{0}]", toReturn);
	}

	return toReturn;
}
 
Example 13
Source File: BIObjectDAOHibImpl.java    From Knowage-Server with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Load bi object for detail.
 *
 * @param id the id
 * @return the BI object
 * @throws EMFUserError the EMF user error
 * @see it.eng.spagobi.analiticalmodel.document.dao.IBIObjectDAO#loadBIObjectForDetail(java.lang.Integer)
 */
@Override
public BIObject loadBIObjectForDetail(Integer id) throws EMFUserError {
	Monitor monitor = MonitorFactory.start("it.eng.spagobi.analiticalmodel.document.dao.BIObjectDAOHibImpl.loadBIObjectForDetail(Integer id)");
	logger.debug("IN");
	BIObject biObject = null;
	Session aSession = null;
	Transaction tx = null;
	try {
		aSession = getSession();
		tx = aSession.beginTransaction();
		// String hql = " from SbiObjects where biobjId = " + id;
		String hql = " from SbiObjects where biobjId = ?";
		Query hqlQuery = aSession.createQuery(hql);
		hqlQuery.setInteger(0, id.intValue());
		SbiObjects hibObject = (SbiObjects) hqlQuery.uniqueResult();
		if (hibObject != null) {
			biObject = toBIObject(hibObject, aSession);
		} else {
			logger.warn("Unable to load document whose id is equal to [" + id + "]");
		}
		tx.commit();
	} catch (HibernateException he) {
		logger.error(he);
		if (tx != null)
			tx.rollback();
		throw new EMFUserError(EMFErrorSeverity.ERROR, 100);
	} finally {
		if (aSession != null) {
			if (aSession.isOpen())
				aSession.close();
		}
	}
	logger.debug("OUT");
	monitor.stop();
	return biObject;
}
 
Example 14
Source File: DocumentExecutionUtils.java    From Knowage-Server with GNU Affero General Public License v3.0 5 votes vote down vote up
public static List<DocumentDriverRuntime> getParameters(BIObject document, String executionRole, Locale locale, String modality, List<String> parsFromCross,
		boolean loadAdmissible, DocumentRuntime dum) {
	Monitor monitor = MonitorFactory.start("Knowage.DocumentExecutionUtils.getParameters");
	List<DocumentDriverRuntime> parametersForExecution = null;
	try {
		parametersForExecution = new ArrayList<DocumentDriverRuntime>();
		List<BIObjectParameter> parameters = document.getDrivers();
		if (parameters != null && parameters.size() > 0) {
			Iterator<BIObjectParameter> it = parameters.iterator();
			while (it.hasNext()) {
				BIObjectParameter parameter = it.next();

				// check if coming from cross
				boolean comingFromCross = false;
				if (parsFromCross != null && parsFromCross.contains(parameter.getParameterUrlName())) {
					comingFromCross = true;
				}

				parametersForExecution
						.add(new DocumentDriverRuntime(parameter, executionRole, locale, document, comingFromCross, loadAdmissible, dum, parameters));
			}
		}
	} finally {
		monitor.stop();
	}
	return parametersForExecution;
}
 
Example 15
Source File: VersionResource.java    From Knowage-Server with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Delete the versions
 *
 * @param versionsToDelete
 *            its the serialization of a list with the ids of the version to
 *            remove. Example. "1 , 2, 4"
 * @return
 */
@POST
@Path("/delete/{versionsToDelete}")
public String deleteVersion(@PathParam("versionsToDelete") String versionsToDelete) {
	logger.debug("IN");
	Monitor totalTimeMonitor = MonitorFactory.start("WhatIfEngine/it.eng.spagobi.engines.whatif.api.VersionResource.deleteVersion.totalTime");
	getVersionBusiness().deleteVersions(versionsToDelete);
	logger.debug("OUT");
	WhatIfEngineInstance ei = getWhatIfEngineInstance();
	PivotModel model = ei.getPivotModel();
	String table = renderModel(model);
	logger.debug("OUT");
	totalTimeMonitor.stop();
	return table;
}
 
Example 16
Source File: InteractiveMapRenderer.java    From Knowage-Server with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public File renderMap(IMapProvider mapProvider, IDataMartProvider datamartProvider, String outputFormat) throws SvgViewerEngineRuntimeException {

	Monitor totalTimeMonitor = null;
	Monitor totalTimePerFormatMonitor = null;

	try {

		totalTimeMonitor = MonitorFactory.start("GeoEngine.drawMapAction.renderMap.totalTime");
		totalTimePerFormatMonitor = MonitorFactory.start("GeoEngine.drawMapAction.renderMap." + outputFormat + ".totalTime");

		if (outputFormat.equalsIgnoreCase(SvgViewerEngineConstants.SVG)) {
			return renderSVGMap(mapProvider, datamartProvider);
		} else if (outputFormat.equalsIgnoreCase(SvgViewerEngineConstants.DSVG)) {
			return renderDSVGMap(mapProvider, datamartProvider, false);
		} else if (outputFormat.equalsIgnoreCase(SvgViewerEngineConstants.XDSVG)) {
			return renderDSVGMap(mapProvider, datamartProvider, true);
		} else if (outputFormat.equalsIgnoreCase(SvgViewerEngineConstants.JPEG)) {
			return renderSVGMap(mapProvider, datamartProvider);
		}
	} finally {
		if (totalTimePerFormatMonitor != null)
			totalTimePerFormatMonitor.stop();
		if (totalTimeMonitor != null)
			totalTimeMonitor.stop();
	}

	return renderDSVGMap(mapProvider, datamartProvider, true);
}
 
Example 17
Source File: ObjectsAccessVerifier.java    From Knowage-Server with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * Private method called by the corrispondent public method canExec. Executes roles functionalities control .
 *
 * @param folder
 *            The lowFunctionality
 * @param profile
 *            user profile
 * @return A boolean control value
 */
private static boolean canExecInternal(LowFunctionality folder, IEngUserProfile profile) {
	logger.debug("IN");
	Monitor monitor = MonitorFactory.start("spagobi.core.ObjectAccessVerifier.canExecInternal");

	Collection roles = null;

	try {
		roles = ((UserProfile) profile).getRolesForUse();
	} catch (EMFInternalError emfie) {
		logger.error("EMFInternalError in profile.getRoles");
		logger.debug("OUT.return false");
		monitor.stop();
		return false;
	}

	if (folder.getCodType().equalsIgnoreCase("USER_FUNCT")) {
		monitor.stop();
		return true;
	}

	Role[] execRoles = folder.getExecRoles();
	List execRoleNames = new ArrayList();
	for (int i = 0; i < execRoles.length; i++) {
		Role role = execRoles[i];
		execRoleNames.add(role.getName());
	}

	Iterator iterRoles = roles.iterator();
	String roleName = "";
	while (iterRoles.hasNext()) {
		roleName = (String) iterRoles.next();
		if (execRoleNames.contains(roleName)) {
			logger.debug("OUT.return true");
			monitor.stop();
			return true;
		}
	}
	logger.debug("OUT.return false");
	monitor.stop();
	return false;

}
 
Example 18
Source File: DocumentExecutionResource.java    From Knowage-Server with GNU Affero General Public License v3.0 4 votes vote down vote up
private String BuildEngineUrlString(JSONObject reqVal, BIObject obj, HttpServletRequest req, String isForExport, String cockpitSelections)
		throws JSONException {
	Monitor buildEngineUrlStringMonitor = MonitorFactory.start("Knowage.DocumentExecutionResource.buildEngineUrlString");

	String ret = "";

	if (obj.getBiObjectTypeCode().equals(SpagoBIConstants.OLAP_TYPE_CODE)) {
		JSONObject parameters = reqVal.getJSONObject("parameters");
		if (parameters.length() > 0) {

			String subViewObjectID = parameters.optString("subobj_id");
			String subViewObjectName = parameters.optString("subobj_name");
			String subViewObjectDescription = parameters.optString("subobj_description");
			String subViewObjectVisibility = parameters.optString("subobj_visibility");

			if (!StringUtilities.isEmpty(subViewObjectID)) {
				ret += "&" + AbstractEngineStartAction.SUBOBJ_ID + "=" + subViewObjectID;
			}
			if (!StringUtilities.isEmpty(subViewObjectName)) {
				ret += "&" + AbstractEngineStartAction.SUBOBJ_NAME + "=" + subViewObjectName;
			}
			if (!StringUtilities.isEmpty(subViewObjectDescription)) {
				ret += "&" + AbstractEngineStartAction.SUBOBJ_DESCRIPTION + "=" + subViewObjectDescription;
			}
			if (!StringUtilities.isEmpty(subViewObjectVisibility)) {
				ret += "&" + AbstractEngineStartAction.SUBOBJ_VISIBILITY + "=" + subViewObjectVisibility;
			}
		}
	}

	// REPORT BIRT - JASPER
	// MOBILE
	if (obj.getBiObjectTypeCode().equals(SpagoBIConstants.REPORT_TYPE_CODE) && obj.getEngine() != null
			&& (obj.getEngine().getLabel().equals(SpagoBIConstants.BIRT_ENGINE_LABEL)
					|| obj.getEngine().getLabel().equals(SpagoBIConstants.JASPER_ENGINE_LABEL))
			&& (req.getHeader("User-Agent").indexOf("Mobile") != -1 || req.getHeader("User-Agent").indexOf("iPad") != -1
					|| req.getHeader("User-Agent").indexOf("iPhone") != -1)) {
		ret = ret + "&outputType=PDF";
	}
	// COCKPIT
	if (obj.getBiObjectTypeCode().equals(SpagoBIConstants.DOCUMENT_COMPOSITE_TYPE)) {
		if (!("".equalsIgnoreCase(isForExport))) {
			ret += "&IS_FOR_EXPORT=" + isForExport;
			if (!("".equalsIgnoreCase(cockpitSelections))) {
				ret += "&COCKPIT_SELECTIONS=" + cockpitSelections;
			}
		}
	}
	buildEngineUrlStringMonitor.stop();
	return ret;
}
 
Example 19
Source File: QbeQueryResource.java    From Knowage-Server with GNU Affero General Public License v3.0 4 votes vote down vote up
@POST
@Path("/executeQuery")
@Produces(MediaType.APPLICATION_JSON)
public Response executeQuery(@javax.ws.rs.core.Context HttpServletRequest req, @QueryParam("start") String startS, @QueryParam("limit") String limitS,
		@QueryParam("currentQueryId") String id) {

	Integer limit = null;
	Integer start = null;
	Integer maxSize = null;
	IDataStore dataStore = null;
	Query query = null;

	Integer resultNumber = null;
	JSONObject gridDataFeed = new JSONObject();
	JSONObject jsonEncodedReq = null;
	Monitor totalTimeMonitor = null;
	Monitor errorHitsMonitor = null;

	try {
		totalTimeMonitor = MonitorFactory.start("QbeEngine.executeQueryAction.totalTime");
		jsonEncodedReq = RestUtilities.readBodyAsJSONObject(req);

		JSONArray pars = jsonEncodedReq.optJSONArray(DataSetConstants.PARS);
		addParameters(pars);

		query = getQueryFromJson(id, query, jsonEncodedReq);

		SqlFilterModelAccessModality sqlModality = new SqlFilterModelAccessModality();
		UserProfile userProfile = (UserProfile) getEnv().get(EngineConstants.ENV_USER_PROFILE);

		logger.debug("Parameter [" + "limit" + "] is equals to [" + limit + "]");

		IModelAccessModality accessModality = getEngineInstance().getDataSource().getModelAccessModality();

		if (handleTimeFilter) {
			new TimeAggregationHandler(getEngineInstance().getDataSource()).handleTimeFilters(query);
		}

		Query filteredQuery = accessModality.getFilteredStatement(query, this.getEngineInstance().getDataSource(), userProfile.getUserAttributes());

		if (hasAmbiguities(filteredQuery)) {
			throw new SpagoBIRuntimeException("There is ambiguity present in the query");
		}
		// updateQueryGraphInQuery(filteredQuery, true, modelEntities);
		Map<String, Map<String, String>> inlineFilteredSelectFields = filteredQuery.getInlineFilteredSelectFields();

		boolean thereAreInlineTemporalFilters = inlineFilteredSelectFields != null && inlineFilteredSelectFields.size() > 0;
		if (thereAreInlineTemporalFilters) {
			limit = 0;
		}
		if (startS != null && !startS.equals("")) {
			start = Integer.parseInt(startS);
		}

		if (limitS != null && !limitS.equals("")) {
			limit = Integer.parseInt(limitS);
		}
		dataStore = executeQuery(start, limit, filteredQuery);
		if (thereAreInlineTemporalFilters) {
			dataStore = new TimeAggregationHandler(getEngineInstance().getDataSource()).handleTimeAggregations(filteredQuery, dataStore);
		}
		resultNumber = (Integer) dataStore.getMetaData().getProperty("resultNumber");

		logger.debug("Total records: " + resultNumber);
		boolean overflow = maxSize != null && resultNumber >= maxSize;
		if (overflow) {
			logger.warn("Query results number [" + resultNumber + "] exceeds max result limit that is [" + maxSize + "]");
			// auditlogger.info("[" + userProfile.getUserId() +
			// "]:: max result limit [" + maxSize + "] exceeded with SQL: "
			// + sqlQuery);
		}
		gridDataFeed = serializeDataStore(dataStore);
		return Response.ok(gridDataFeed.toString()).build();
	} catch (Throwable t) {
		errorHitsMonitor = MonitorFactory.start("QbeEngine.errorHits");
		errorHitsMonitor.stop();
		throw new SpagoBIServiceException(this.request.getPathInfo(), t.getMessage(), t);
	} finally {
		if (totalTimeMonitor != null)
			totalTimeMonitor.stop();
		logger.debug("OUT");
	}

}
 
Example 20
Source File: UpdateRecordsAction.java    From Knowage-Server with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void service(SourceBean request, SourceBean response) {

	Monitor totalTimeMonitor = null;
	Monitor errorHitsMonitor = null;

	logger.debug("IN");

	try {

		super.service(request, response);

		totalTimeMonitor = MonitorFactory.start("QbeEngine.updateRecordsAction.totalTime");

		Vector<Integer> idsToReturn = executeUpdate();

		try {
			JSONArray arrays = new JSONArray();
			if (idsToReturn != null && idsToReturn.size() > 0) {
				for (Iterator iterator = idsToReturn.iterator(); iterator.hasNext();) {
					Integer integer = (Integer) iterator.next();
					arrays.put(integer);
				}
			}

			Map<String, Object> properties = new HashMap<String, Object>();
			properties.put("keyField", keyColumn);
			properties.put("ids", arrays);

			JSONObject jsonObject = new JSONObject(properties);

			// JSONAcknowledge jsonAcknowledge = new JSONAcknowledge();
			JSONSuccess success = new JSONSuccess(jsonObject);

			writeBackToClient(success);
		} catch (IOException e) {
			String message = "Impossible to write back the responce to the client";
			throw new SpagoBIEngineServiceException(getActionName(), message, e);
		}

	} catch (Throwable t) {
		errorHitsMonitor = MonitorFactory.start("QbeEngine.updateRecordsAction.errorHits");
		errorHitsMonitor.stop();
		throw SpagoBIEngineServiceExceptionHandler.getInstance().getWrappedException(getActionName(), getEngineInstance(), t);
	} finally {
		if (totalTimeMonitor != null)
			totalTimeMonitor.stop();
		logger.debug("OUT");
	}
}