com.jfinal.plugin.activerecord.CPI Java Examples

The following examples show how to use com.jfinal.plugin.activerecord.CPI. 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: ElasticSearcher.java    From jpress with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void updateArticle(Article article) {
    UpdateRequest updateRequest = new UpdateRequest(index, type, article.getId().toString());
    Map<String, Object> map = new HashMap<>();
    map.putAll(CPI.getAttrs(article));
    updateRequest.doc(map);

    try {
        UpdateResponse response = client.update(updateRequest, RequestOptions.DEFAULT);
        if (LogKit.isDebugEnabled()) {
            LogKit.debug(response.toString());
        }
    } catch (Exception e) {
        LOG.error(e.toString(), e);
    }
}
 
Example #2
Source File: ElasticSearcher.java    From jpress with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void updateProduct(Product product) {
    UpdateRequest updateRequest = new UpdateRequest(index, type, product.getId().toString());
    Map<String, Object> map = new HashMap<>();
    map.putAll(CPI.getAttrs(product));
    updateRequest.doc(map);

    try {
        UpdateResponse response = client.update(updateRequest, RequestOptions.DEFAULT);
        if (LogKit.isDebugEnabled()) {
            LogKit.debug(response.toString());
        }
    } catch (Exception e) {
        LOG.error(e.toString(), e);
    }
}
 
Example #3
Source File: Action.java    From jpress with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static Action addAction(Article article) {
    Action action = new Action();
    action.cmd = "ADD";
    action.fields = new HashMap();
    action.fields.putAll(CPI.getAttrs(article));
    return action;
}
 
Example #4
Source File: Action.java    From jpress with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static Action addAction(Product product) {
    Action action = new Action();
    action.cmd = "ADD";
    action.fields = new HashMap();
    action.fields.putAll(CPI.getAttrs(product));
    return action;
}
 
Example #5
Source File: JsonUtils.java    From jfinal-weixin with Apache License 2.0 5 votes vote down vote up
/**
 * 将Collection<Model>转换为json字符串
 * @param models
 * @return JsonString
 */
public static String toJson(Collection<Model<? extends Model<?>>> models) {
	List<Map<String, Object>> list = new ArrayList<Map<String,Object>>();
	for (Model<? extends Model<?>> model : models) {
		list.add(CPI.getAttrs(model));
	}
	return toJson(list);
}
 
Example #6
Source File: JsonUtils.java    From jfinal-weixin with Apache License 2.0 2 votes vote down vote up
/**
 * 将model转为json字符串
 * @param model
 * @return JsonString
 */
public static String toJson(Model<? extends Model<?>> model) {
	return toJson(CPI.getAttrs(model));
}