当前位置: 首页>>代码示例>>Java>>正文


Java Address类代码示例

本文整理汇总了Java中com.erudika.para.core.Address的典型用法代码示例。如果您正苦于以下问题:Java Address类的具体用法?Java Address怎么用?Java Address使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Address类属于com.erudika.para.core包,在下文中一共展示了Address类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findNearby

import com.erudika.para.core.Address; //导入依赖的package包/类
@Override
public <P extends ParaObject> List<P> findNearby(String appid, String type,
	String query, int radius, double lat, double lng, Pager... pager) {

	if (StringUtils.isBlank(type) || StringUtils.isBlank(appid)) {
		return Collections.emptyList();
	}
	if (StringUtils.isBlank(query)) {
		query = "*";
	}
	// find nearby Address objects
	Pager page = getPager(pager);
	QueryBuilder qb1 = geoDistanceQuery("latlng").point(lat, lng).distance(radius, DistanceUnit.KILOMETERS);
	SearchHits hits1 = searchQueryRaw(appid, Utils.type(Address.class), qb1, page);
	page.setLastKey(null); // will cause problems if not cleared

	if (hits1 == null) {
		return Collections.emptyList();
	}

	if (type.equals(Utils.type(Address.class))) {
		return searchQuery(appid, hits1);
	}

	// then find their parent objects
	String[] parentids = new String[hits1.getHits().length];
	for (int i = 0; i < hits1.getHits().length; i++) {
		Object pid = hits1.getAt(i).getSourceAsMap().get(Config._PARENTID);
		if (pid != null) {
			parentids[i] = (String) pid;
		}
	}

	QueryBuilder qb2 = boolQuery().must(queryStringQuery(qs(query))).filter(idsQuery().addIds(parentids));
	SearchHits hits2 = searchQueryRaw(appid, type, qb2, page);
	return searchQuery(appid, hits2);
}
 
开发者ID:Erudika,项目名称:para-search-elasticsearch,代码行数:38,代码来源:ElasticSearch.java

示例2: post

import com.erudika.para.core.Address; //导入依赖的package包/类
@PostMapping("/questions/ask")
public String post(@RequestParam(required = false) String location, @RequestParam(required = false) String latlng,
		@RequestParam(required = false) String address, HttpServletRequest req, Model model) {
	if (utils.isAuthenticated(req)) {
		Profile authUser = utils.getAuthUser(req);
		Question q = utils.populate(req, new Question(), "title", "body", "tags|,", "location");
		q.setCreatorid(authUser.getId());
		Map<String, String> error = utils.validate(q);
		if (error.isEmpty()) {
			q.setLocation(location);
			String qid = q.create();
			if (!StringUtils.isBlank(latlng)) {
				Address addr = new Address();
				addr.setAddress(address);
				addr.setCountry(location);
				addr.setLatlng(latlng);
				addr.setParentid(qid);
				addr.setCreatorid(authUser.getId());
				pc.create(addr);
			}
			authUser.setLastseen(System.currentTimeMillis());
		} else {
			model.addAttribute("error", error);
			model.addAttribute("path", "questions.vm");
			model.addAttribute("includeGMapsScripts", true);
			model.addAttribute("askSelected", "navbtn-hover");
			return "base";
		}
		return "redirect:" + q.getPostLink(false, false);
	}
	return "redirect:" + SIGNINLINK + "?returnto=" + QUESTIONSLINK + "/ask";
}
 
开发者ID:Erudika,项目名称:scoold,代码行数:33,代码来源:QuestionsController.java

示例3: init

import com.erudika.para.core.Address; //导入依赖的package包/类
public static void init() {
	CoreUtils.getInstance().setSearch(s);
	u = new User("111");
	u.setName("John Doe");
	u.setGroups(User.Groups.USERS.toString());
	u.setEmail("[email protected]");
	u.setIdentifier(u.getEmail());
	u.setTimestamp(1000000000L);
	u.setPassword("123456");
	u.setTags(CoreUtils.getInstance().addTags(u.getTags(), "one", "two", "three"));

	u1 = new User("222");
	u1.setName("Joe Black");
	u1.setGroups(User.Groups.USERS.toString());
	u1.setEmail("[email protected]");
	u1.setIdentifier(u1.getEmail());
	u1.setTimestamp(Utils.timestamp());
	u1.setPassword("123456");
	u1.setTags(CoreUtils.getInstance().addTags(u1.getTags(), "two", "four", "three"));

	u2 = new User("333");
	u2.setName("Ann Smith");
	u2.setGroups(User.Groups.USERS.toString());
	u2.setEmail("[email protected]");
	u2.setIdentifier(u2.getEmail());
	u2.setTimestamp(Utils.timestamp());
	u2.setPassword("123456");
	u2.setTags(CoreUtils.getInstance().addTags(u2.getTags(), "four", "five", "three"));

	t = new Tag("test");
	t.setCount(3);
	t.setTimestamp(Utils.timestamp());

	a1 = new Address("adr1");
	a1.setName("Place 1");
	a1.setAddress("NYC");
	a1.setCountry("US");
	a1.setLatlng("40.67,-73.94");
	a1.setParentid(u.getId());
	a1.setCreatorid(u.getId());

	a2 = new Address("adr2");
	a2.setName("Place 2");
	a2.setAddress("NYC");
	a2.setCountry("US");
	a2.setLatlng("40.69,-73.95");
	a2.setParentid(t.getId());
	a2.setCreatorid(t.getId());

	s1 = new Sysprop("s1");
	s1.addProperty("text", "This is a little test sentence. Testing, one, two, three.");
	s1.setTimestamp(Utils.timestamp());

	s2 = new Sysprop("s2");
	s2.addProperty("text", "We are testing this thing. This sentence is a test. One, two.");
	s2.setTimestamp(Utils.timestamp());

	Sysprop linked1 = new Sysprop("link1");
	Sysprop linked2 = new Sysprop("link2");
	linked1.addProperty("text", "hello kitty");
	linked2.addProperty("text", "hello doggy");
	l1 = new Linker("cat", "dog", "id1", "id2");
	l1.addNestedObject(linked1);
	l1.addNestedObject(linked2);

	s.indexAll(Arrays.asList(u, u1, u2, t, s1, s2, a1, a2, l1));
	try {
		Thread.sleep(1000);
	} catch (InterruptedException ex) { }
}
 
开发者ID:Erudika,项目名称:para-search-elasticsearch,代码行数:71,代码来源:SearchTest.java

示例4: searchGeoQuery

import com.erudika.para.core.Address; //导入依赖的package包/类
/**
 * Geopoint distance query. Finds objects located near a center point.
 * @param <P> object type
 * @param dao {@link DAO}
 * @param appid appid
 * @param type object type to search for
 * @param query a geopoint query
 * @param queryString query string for filtering results
 * @param pager a {@link Pager}
 * @return a list of ParaObjects
 */
public static <P extends ParaObject> List<P> searchGeoQuery(DAO dao, String appid, String type,
		Query query, String queryString, Pager... pager) {
	if (StringUtils.isBlank(type) || StringUtils.isBlank(appid)) {
		return Collections.emptyList();
	}
	if (StringUtils.isBlank(queryString)) {
		queryString = "*";
	}
	DirectoryReader ireader = null;
	try {
		Pager page = getPager(pager);
		ireader = getIndexReader(appid);
		if (ireader != null) {
			Document[] hits1 = searchQueryRaw(ireader, appid, Utils.type(Address.class), query, page);
			page.setLastKey(null); // will cause problems if not cleared

			if (hits1.length == 0) {
				return Collections.emptyList();
			}

			if (type.equals(Utils.type(Address.class))) {
				return searchQuery(dao, appid, hits1, page);
			}

			// then searchQuery their parent objects
			ArrayList<String> parentids = new ArrayList<>(hits1.length);
			for (Document doc : hits1) {
				Address address = documentToParaObject(doc);
				if (address != null && !StringUtils.isBlank(address.getParentid())) {
					parentids.add(address.getParentid());
				}
			}

			Builder qsPart = new BooleanQuery.Builder();
			qsPart.add(qs(queryString, MultiFields.getIndexedFields(ireader)), BooleanClause.Occur.MUST);
			Builder filterIdsPart = new BooleanQuery.Builder();
			for (String id : parentids) {
				filterIdsPart.add(new TermQuery(new Term(Config._ID, id)), BooleanClause.Occur.SHOULD);
			}
			qsPart.add(filterIdsPart.build(), BooleanClause.Occur.FILTER);
			Document[] hits2 = searchQueryRaw(ireader, appid, type, qsPart.build(), page);
			return searchQuery(dao, appid, hits2, page);
		}
	} catch (Exception e) {
		logger.error(null, e);
	} finally {
		closeIndexReader(ireader);
	}
	return Collections.emptyList();
}
 
开发者ID:Erudika,项目名称:para,代码行数:62,代码来源:LuceneUtils.java


注:本文中的com.erudika.para.core.Address类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。