• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ObjectContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: performShowConcept

import org.apache.cayenne.ObjectContext; //导入依赖的package包/类
private void performShowConcept(String line) {
	Matcher m = Pattern.compile("s (\\d*)").matcher(line);
	if (m.matches()) {
		try {
			long conceptId = Long.parseLong(m.group(1));
			ObjectContext context = cayenne.get().newContext();
			Concept c = ObjectSelect.query(Concept.class, Concept.CONCEPT_ID.eq(conceptId)).selectOne(context);
			if (c != null) {
				setCurrentConcept(c);
				printConcept(c, false);
			}
			else {
				System.err.println("No concept found with identifier: "+conceptId);
			}
		}
		catch (NumberFormatException e) {
			System.err.println("Invalid concept identifier");
		}
	}
	if ("s".equalsIgnoreCase(line.trim()) && currentConcept() != null) {
		printConcept(currentConcept(), true);
	}
}
 
开发者ID:wardle,项目名称:rsterminology,代码行数:24,代码来源:Browser.java


示例2: processAllDescriptions

import org.apache.cayenne.ObjectContext; //导入依赖的package包/类
/**
 * Create a new index based on all known SNOMED CT descriptions.
 * This may take a *long* time....
 * @throws IOException
 * @throws LockObtainFailedException
 * @throws CorruptIndexException
 *
 */
public void processAllDescriptions(ObjectContext context) throws CorruptIndexException, LockObtainFailedException, IOException {
	IndexWriter writer = createOrLoadIndexWriter(indexFile(), analyser());
	EJBQLQuery countQuery = new EJBQLQuery("select COUNT(d) FROM Description d");
	@SuppressWarnings("unchecked") long count = ((List<Long>) context.performQuery(countQuery)).get(0);
	SelectQuery<Description> query = SelectQuery.query(Description.class);
	System.out.println("Updating search index:");
	CayenneUtility.timedBatchIterator(context, query, BATCH_ITERATOR_COUNT, count, (batch) -> {
		try {
			for (Description d : batch) {
				processDescription(writer, d);
			}
			writer.commit();			
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	});
	System.out.println("Merging segments...");
	writer.forceMerge(1);
	writer.close();
	System.out.println("Finished updating search index");
	_searcher = createSearcher();		// create a new searcher now the index has changed.
}
 
开发者ID:wardle,项目名称:rsterminology,代码行数:31,代码来源:Search.java


示例3: update

import org.apache.cayenne.ObjectContext; //导入依赖的package包/类
@Override
void update(Relationship r, String[] csv) {
	ObjectContext context = r.getObjectContext();
	r.setDateUpdated(_dateCreated);
	r.setRelationshipId(relationshipId(csv));
	r.setCharacteristicType(characteristicType(csv));
	r.setRefinability(refinability(csv));
	r.setRelationshipGroup(relationshipGroup(csv));
	Concept type = ObjectSelect.query(Concept.class, Concept.CONCEPT_ID.eq(relationTypeConceptId(csv))).selectOne(context);
	Concept source = ObjectSelect.query(Concept.class, Concept.CONCEPT_ID.eq(sourceConceptId(csv))).selectOne(context);
	Concept target = ObjectSelect.query(Concept.class, Concept.CONCEPT_ID.eq(targetConceptId(csv))).selectOne(context);
	if (type != null && source != null && target != null) {
		r.setRelationshipTypeConcept(type);
		r.setSourceConcept(source);
		r.setTargetConcept(target);
	}
	else {
		System.err.println("Could not import relationship " + relationshipId(csv) + 
				": One or more concepts not found. Source:" + source + 
				" Type:" + type + " Target:" + target);
		context.deleteObject(r);
	}
}
 
开发者ID:wardle,项目名称:rsterminology,代码行数:24,代码来源:ParseRf1.java


示例4: timedBatchIterator

import org.apache.cayenne.ObjectContext; //导入依赖的package包/类
/**
 * A very simple helper method to iterate through a select query showing progress.
 * Most useful in a command line utility.
 */
public static <T> void timedBatchIterator(ObjectContext context, SelectQuery<T> query, int batchSize, long count, Consumer<List<T>> forEach) {
	long i = 1;
	long batches = (count / batchSize) + (count % batchSize > 0 ? 1 : 0);
	long estimated = 0;
	System.out.println("Processing " + count + ((batches == 0) ? "" : (" in " + batches + " batches...")));
	long start = System.currentTimeMillis();
	try (ResultBatchIterator<T> iterator = query.batchIterator(context, batchSize)) {
		for(List<T> batch : iterator) {
			System.out.print("\rProcessing batch " + i + "/" + batches + (estimated == 0 ? "" : " Remaining: ~" + estimated / 60000 + " min   "));
			forEach.accept(batch);
			i++;
			long elapsed = System.currentTimeMillis() - start;
			estimated = (batches - i) * elapsed / i;
		}
	}
	long duration = System.currentTimeMillis() - start;
	System.out.println("\nFinished processing : " + count + " Total time:" + duration / 60000 + " minutes");
}
 
开发者ID:wardle,项目名称:rsterminology,代码行数:23,代码来源:CayenneUtility.java


示例5: timingForRecursiveParents

import org.apache.cayenne.ObjectContext; //导入依赖的package包/类
private void timingForRecursiveParents(ObjectContext context, long conceptId) {
	// try method 1, fetch concept and then fetch recursive parents
	long startTime = System.nanoTime();
	Concept ms1 = ObjectSelect.query(Concept.class, Concept.CONCEPT_ID.eq(26078007L)).selectOne(context);
	List<Long> parents = ParentCache.fetchRecursiveParentsForConcept(context, 26078007L);
	long duration = (System.nanoTime() - startTime) / 1000000;
	System.out.println("Time taken for fetch and then fetch: " + duration + " ms");		

	startTime = System.nanoTime();
	// try method 2, fetch concept and prefetch parents from cache in database
	ObjectSelect<Concept> q = ObjectSelect.query(Concept.class, Concept.CONCEPT_ID.eq(26078007L));
	q.prefetch(Concept.RECURSIVE_PARENT_CONCEPTS.joint());
	Concept ms = context.selectFirst(q);
	Set<Long> parents2 = ms.getCachedRecursiveParents();
	duration = (System.nanoTime() - startTime) / 1000000;
	System.out.println("Time taken for fetch with prefetch " + duration + " ms");		

	// are methods equivalent?  this may fail if database is inconsistent
	// assertTrue(parents2.equals(new HashSet<Long>(parents)));
}
 
开发者ID:wardle,项目名称:rsterminology,代码行数:21,代码来源:TestSnomedCt.java


示例6: testConceptCreation

import org.apache.cayenne.ObjectContext; //导入依赖的package包/类
@Test
public void testConceptCreation() {
	ObjectContext context = getRuntime().newContext();
	Concept c = context.newObject(Concept.class);
	c.setConceptId(123456L);		// an invalid concept identifier
	c.setFullySpecifiedName("A test concept");
	c.setCtvId("ctvId");
	c.setIsPrimitive(0);
	c.setSnomedId("snomedid");
	c.setConceptStatusCode(0);
	try {
		context.commitChanges();
		assertFalse("Didn't catch validation errors", true);
	}
	catch (ValidationException e) {
		ValidationResult r = e.getValidationResult();
		assertTrue(r.hasFailures(c));
		assertTrue("Invalid concept identifier".equals(r.getFailures().get(0).getError()));
	}
	
}
 
开发者ID:wardle,项目名称:rsterminology,代码行数:22,代码来源:TestSnomedCt.java


示例7: testSearchMedications

import org.apache.cayenne.ObjectContext; //导入依赖的package包/类
@Test
public void testSearchMedications() throws CorruptIndexException, ParseException, IOException {
	ObjectContext context = getRuntime().newContext();
	Search search = Search.getInstance();
	Builder b = new Search.Request.Builder(search);
	List<ResultItem> sAmlodipine = b.searchUsingQueryParser("amlodip*").setMaxHits(1).withFilters(Search.Filter.DMD_VTM_OR_TF).build().search();
	assertEquals(1, sAmlodipine.size());
	Concept amlodipine = ObjectSelect.query(Concept.class, Concept.CONCEPT_ID.eq(sAmlodipine.get(0).getConceptId())).selectOne(context);
	assertNotNull(amlodipine);
	assertTrue(Vtm.isA(amlodipine));		// this should be a VTM
	List<ResultItem> aMadopar = b.search("madopar").setMaxHits(1).withFilters(Search.Filter.DMD_VTM_OR_TF).build().search();
	Concept madopar = ObjectSelect.query(Concept.class, Concept.CONCEPT_ID.eq(aMadopar.get(0).getConceptId())).selectOne(context);
	assertTrue(Tf.isA(madopar));

	assertEquals(0, b.search("madopar").clearFilters().withDirectParent(Dmd.Product.VIRTUAL_THERAPEUTIC_MOIETY.conceptId).build().search().size());
	assertEquals(0, b.search("madopar").clearFilters().withDirectParent(Dmd.Product.VIRTUAL_MEDICINAL_PRODUCT.conceptId).build().search().size());
	assertEquals(0, b.search("madopar").clearFilters().withDirectParent(Dmd.Product.VIRTUAL_MEDICINAL_PRODUCT_PACK.conceptId).build().search().size());
	assertNotEquals(0, b.search("madopar").clearFilters().withDirectParent(Dmd.Product.TRADE_FAMILY.conceptId).build().search().size());
	assertNotEquals(0, b.search("madopar").clearFilters().withDirectParent(Dmd.Product.ACTUAL_MEDICINAL_PRODUCT.conceptId).build().search().size());
	assertNotEquals(0, b.search("madopar").clearFilters().withDirectParent(Dmd.Product.ACTUAL_MEDICINAL_PRODUCT_PACK.conceptId).build().search().size());

}
 
开发者ID:wardle,项目名称:rsterminology,代码行数:23,代码来源:TestSnomedCt.java


示例8: testRequest

import org.apache.cayenne.ObjectContext; //导入依赖的package包/类
@Test
public void testRequest() throws CorruptIndexException, IOException, ParseException {
	ObjectContext context = getRuntime().newContext();
	Search search = Search.getInstance();
	List<ResultItem> sAmlodipine = new Search.Request.Builder(search).searchUsingQueryParser("amlodip*").withFilters(Search.Filter.DMD_VTM_OR_TF, Search.Filter.CONCEPT_ACTIVE).setMaxHits(1).build().search();
	assertEquals(1, sAmlodipine.size());
	Concept amlodipine = ObjectSelect.query(Concept.class, Concept.CONCEPT_ID.eq(sAmlodipine.get(0).getConceptId())).selectOne(context);
	assertTrue(Vtm.isA(amlodipine));
	
	List<ResultItem> sMultipleSclerosisInDrugs = new Search.Request.Builder(search).searchUsingQueryParser("multiple sclerosis").withFilters(Search.Filter.DMD_VTM_OR_TF).build().search();
	assertEquals(0, sMultipleSclerosisInDrugs.size());
	
	List<ResultItem> sMultipleSclerosis = new Search.Request.Builder(search).search("multiple sclerosis").withRecursiveParent(Category.DISEASE.conceptId).setMaxHits(1).build().search();
	assertEquals(1, sMultipleSclerosis.size());
	
	List<ResultItem> sMs = new Search.Request.Builder(search).search("ms").withRecursiveParent(Category.DISEASE.conceptId).withFilters(Search.Filter.CONCEPT_ACTIVE).setMaxHits(200).build().search();
	//sMs.forEach(ri -> System.out.println(ri));
	assertTrue(sMs.stream().anyMatch(ri -> ri.getConceptId()==24700007L));	// multiple sclerosis
	assertTrue(sMs.stream().anyMatch(ri -> ri.getConceptId()==79619009L));		// mitral stenosis
}
 
开发者ID:wardle,项目名称:rsterminology,代码行数:21,代码来源:TestSnomedCt.java


示例9: testLocale

import org.apache.cayenne.ObjectContext; //导入依赖的package包/类
@Test
public void testLocale() {
	ObjectContext context = getRuntime().newContext();
	Concept haemophilia = ObjectSelect.query(Concept.class, Concept.CONCEPT_ID.eq(90935002L)).selectOne(context);
	assertNotNull(haemophilia);
	// haemophilia has two preferred descriptions one for US and one for GB
	assertTrue(haemophilia.getDescriptions().stream()
			.filter(d -> d.isPreferred())
			.count() > 1);
	Description preferredGB = haemophilia.getPreferredDescription("en-GB").get();
	assertNotNull(preferredGB);
	assertTrue(preferredGB.isPreferred());
	assertTrue(preferredGB.isActive());
	assertEquals("en-GB", preferredGB.getLanguageCode());
	Description preferredUS = haemophilia.getPreferredDescription("en-US").get();
	assertEquals("en-US", preferredUS.getLanguageCode());
	
	Concept beclametasone = ObjectSelect.query(Concept.class, Concept.CONCEPT_ID.eq(1389007L)).selectOne(context);
	assertNotNull(beclametasone);
	Description bGp = beclametasone.getPreferredDescription("en-GB").get();
	assertTrue(bGp.isActive());

}
 
开发者ID:wardle,项目名称:rsterminology,代码行数:24,代码来源:TestSnomedCt.java


示例10: testSomeVmps

import org.apache.cayenne.ObjectContext; //导入依赖的package包/类
@Test
public void testSomeVmps() {
	ObjectContext context = getRuntime().newContext();
	Expression exp = Concept.PARENT_RELATIONSHIPS.dot(Relationship.TARGET_CONCEPT.dot(Concept.CONCEPT_ID)).eq(Dmd.Product.VIRTUAL_MEDICINAL_PRODUCT.conceptId).andExp(Concept.PARENT_RELATIONSHIPS.dot(Relationship.RELATIONSHIP_TYPE_CONCEPT.dot(Concept.CONCEPT_ID)).eq(RelationType.IS_A.conceptId));
	SelectQuery<Concept> query = SelectQuery.query(Concept.class, exp);
	query.setFetchLimit(500);
	try (ResultBatchIterator<Concept> iterator = query.batchIterator(context, 100)) {
		for(List<Concept> vmps : iterator) {
			for (Concept c : vmps) {
				assertTrue(Vmp.isA(c));
				Vmp vmp = new Vmp(c);
				vmp.getAmps().forEach(amp -> {
					long count = amp.getDispensedDoseForms().count();
					if (count == 0) {
					}
				});
			}
		}
	}
}
 
开发者ID:wardle,项目名称:rsterminology,代码行数:21,代码来源:TestPrescribing.java


示例11: testDmd

import org.apache.cayenne.ObjectContext; //导入依赖的package包/类
@Test
public void testDmd() {
	ObjectContext context = getRuntime().newContext();
	Amp nifedipress = new Amp(ObjectSelect.query(Concept.class, Concept.CONCEPT_ID.eq(7855311000001102L)).selectOne(context));
	assertEquals(2, nifedipress.getExcipients().count());		//lactose and polysorbate
	
	assertTrue(nifedipress.isAvailable());	// this is currently true, but may change in the future
	
	Amp istin = new Amp(ObjectSelect.query(Concept.class, Concept.CONCEPT_ID.eq(5523911000001100L)).selectOne(context));
	assertEquals(0, istin.getExcipients().count());		// Excipient not declared (qualifier value) 8653301000001102
	assertTrue(istin.isAvailable());
	istin.getVtms().forEach(vtm -> assertTrue(vtm.isPrescribable()));
	
	Vmp rofecoxib = new Vmp(ObjectSelect.query(Concept.class, Concept.CONCEPT_ID.eq(330162006L)).selectOne(context));
	assertFalse(rofecoxib.isAvailable());	// rofecoxib isn't available anymore
	assertFalse(rofecoxib.isPrescribable());	// and so isn't prescribable either
	rofecoxib.getAmps().forEach(amp -> assertFalse(amp.isAvailable()));	// none of the AMPs are available either.
	rofecoxib.getTfs().forEach(tf -> assertFalse(tf.isPrescribable()));	// likewise for the TFs
	rofecoxib.getVtms().forEach(vtm -> assertFalse(vtm.isPrescribable()));
}
 
开发者ID:wardle,项目名称:rsterminology,代码行数:21,代码来源:TestPrescribing.java


示例12: testInvalidate_CustomData

import org.apache.cayenne.ObjectContext; //导入依赖的package包/类
@Test
public void testInvalidate_CustomData() {

    ObjectContext context = SERVER_RUNTIME.newContext();

    // make sure Cayenne-specific caches are created...
    ObjectSelect<Table1> g1 = ObjectSelect.query(Table1.class).localCache("cayenne1");
    assertEquals(0, g1.select(context).size());

    // add custom data
    CacheManager cacheManager = TEST_RUNTIME.getInstance(CacheManager.class);
    Cache<String, String> cache = cacheManager.getCache("cayenne1");
    cache.put("a", "b");

    assertEquals("b", cache.get("a"));


    // generate commit event
    context.newObject(Table1.class);
    context.commitChanges();

    // custom cache entries must expire
    assertNull(cache.get("a"));
}
 
开发者ID:bootique,项目名称:bootique-cayenne,代码行数:25,代码来源:CacheInvalidationIT.java


示例13: testCachedQueries

import org.apache.cayenne.ObjectContext; //导入依赖的package包/类
@Test
public void testCachedQueries() {

    ObjectContext context = RUNTIME.newContext();
    ObjectSelect<Table1> g1 = ObjectSelect.query(Table1.class).localCache("g1");
    ObjectSelect<Table1> g2 = ObjectSelect.query(Table1.class).localCache("g2");

    dataManager.getTable(Table1.class).insert(1).insert(45);
    assertEquals(2, g1.select(context).size());

    // we are still cached, must not see the new changes
    dataManager.getTable(Table1.class).insert(2).insert(44);
    assertEquals(2, g1.select(context).size());

    // different cache group - must see the changes
    assertEquals(4, g2.select(context).size());

    // refresh the cache, so that "g1" could see the changes
    RUNTIME.getDataDomain().getQueryCache().removeGroup("g1");
    assertEquals(4, g1.select(context).size());
}
 
开发者ID:bootique,项目名称:bootique-cayenne,代码行数:22,代码来源:CayenneJCacheModuleIT.java


示例14: create

import org.apache.cayenne.ObjectContext; //导入依赖的package包/类
protected T create(ObjectContext context, Class<T> type, Map<String, Object> source) {

		T target = context.newObject(type);

		if (source.isEmpty()) {
			return target;
		}

		for (Map.Entry<String, Object> e : source.entrySet()) {
			TargetPropertyWriter writer = writerFactory.getOrCreateWriter(e.getKey());
			if (writer == null) {
				LOGGER.info("Source contains property not mapped in the target: " + e.getKey() + ". Skipping...");
				continue;
			}
			if (writer.willWrite(target, e.getValue())) {
				writer.write(target, e.getValue());
			}
		}

		return target;
	}
 
开发者ID:nhl,项目名称:link-move,代码行数:22,代码来源:CreateOrUpdateMerger.java


示例15: match

import org.apache.cayenne.ObjectContext; //导入依赖的package包/类
public List<T> match(ObjectContext context, Map<Object, Map<String, Object>> mappedSegment) {

		Collection<Object> keys = mappedSegment.keySet();

		List<Expression> expressions = new ArrayList<>(keys.size());
		for (Object key : keys) {

			Expression e = mapper.expressionForKey(key);
			if (e != null) {
				expressions.add(e);
			}
		}

		// no keys (?)
		if (expressions.isEmpty()) {
			return Collections.emptyList();
		} else {
			return ObjectSelect.query(type).where(ExpressionFactory.or(expressions)).select(context);
		}
	}
 
开发者ID:nhl,项目名称:link-move,代码行数:21,代码来源:TargetMatcher.java


示例16: doExecute

import org.apache.cayenne.ObjectContext; //导入依赖的package包/类
protected <T extends DataObject> void doExecute(DeleteContext<T> context) {

        ObjectContext cayenneContext = CayenneDeleteStartStage.cayenneContext(context);

        // dirty ... we have no concept of DeleteResponse, and we need to
        // pass context to the ObjectMapper, so creating a throwaway response
        // and EntityUpdate .. TODO: somehow need to adapt ObjectMapper to
        // delete responses

        // delete by id
        if (context.isById()) {
            LrEntity<T> lrEntity = metadataService.getLrEntity(context.getType());
            deleteById(context, cayenneContext, lrEntity);
        }
        // delete by parent
        else if (context.getParent() != null) {
            LrEntity<?> parentLrEntity = metadataService.getLrEntity(context.getParent().getType());
            deleteByParent(context, cayenneContext, parentLrEntity);
        }
        // delete all !!
        else {
            deleteAll(context, cayenneContext);
        }
    }
 
开发者ID:nhl,项目名称:link-rest,代码行数:25,代码来源:CayenneDeleteStage.java


示例17: deleteByParent

import org.apache.cayenne.ObjectContext; //导入依赖的package包/类
private <T extends DataObject> void deleteByParent(DeleteContext<T> context, ObjectContext cayenneContext, LrEntity<?> lrParentEntity) {

        EntityParent<?> parent = context.getParent();
        Object parentObject = Util.findById(cayenneContext, parent.getType(), lrParentEntity, parent.getId().get());

        if (parentObject == null) {
            ObjEntity entity = cayenneContext.getEntityResolver().getObjEntity(parent.getType());
            throw new LinkRestException(Response.Status.NOT_FOUND, "No parent object for ID '" + parent.getId()
                    + "' and entity '" + entity.getName() + "'");
        }

        Expression qualifier = parent.qualifier(cayenneContext.getEntityResolver());
        SelectQuery<?> select = SelectQuery.query(context.getType());
        select.andQualifier(qualifier);

        List<?> objects = cayenneContext.select(select);

        cayenneContext.deleteObjects(objects);
        cayenneContext.commitChanges();
    }
 
开发者ID:nhl,项目名称:link-rest,代码行数:21,代码来源:CayenneDeleteStage.java


示例18: getOptionalExistingObject

import org.apache.cayenne.ObjectContext; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private Object getOptionalExistingObject(Class<?> type, ObjectContext context, Object id) {

    ObjEntity entity = context.getEntityResolver().getObjEntity(type);

    // sanity checking...
    if (entity == null) {
        throw new LinkRestException(Response.Status.INTERNAL_SERVER_ERROR, "Unknown entity class: " + type);
    }

    // TODO: should we start using optimistic locking on PK by default
    // instead of SELECT/DELETE|UPDATE?

    String idName = entity.getPrimaryKeyNames().iterator().next();
    ObjectIdQuery select = new ObjectIdQuery(new ObjectId(entity.getName(), idName, id));

    return Cayenne.objectForQuery(context, select);
}
 
开发者ID:nhl,项目名称:link-rest,代码行数:19,代码来源:CayenneUnrelateDataStoreStage.java


示例19: before

import org.apache.cayenne.ObjectContext; //导入依赖的package包/类
@Before
public void before() {

    ObjectContext sharedContext = TestWithCayenneMapping.runtime.newContext();
    cayenneService = mock(ICayennePersister.class);
    when(cayenneService.sharedContext()).thenReturn(sharedContext);
    when(cayenneService.newContext()).thenReturn(TestWithCayenneMapping.runtime.newContext());

    this.filters = new ArrayList<>();
    IAttributeEncoderFactory attributeEncoderFactory = new AttributeEncoderFactoryProvider(Collections.emptyMap()).get();
    IStringConverterFactory stringConverterFactory = mock(IStringConverterFactory.class);
    IRelationshipMapper relationshipMapper = new SenchaRelationshipMapper();

    encoderService = new SenchaEncoderService(this.filters, attributeEncoderFactory, stringConverterFactory,
            relationshipMapper, Collections.<String, PropertyMetadataEncoder>emptyMap());
}
 
开发者ID:nhl,项目名称:link-rest,代码行数:17,代码来源:SenchaEncoderServiceTest.java


示例20: run

import org.apache.cayenne.ObjectContext; //导入依赖的package包/类
@Override
public CommandOutcome run(Cli cli) {
	ObjectContext context = cayenne.get().newContext();
	PrintWriter writer = new PrintWriter(System.out);
	try (CSVWriter csv = new CSVWriter(writer)) {
		SelectQuery<Concept> query = SelectQuery.query(Concept.class, Concept.RECURSIVE_PARENT_CONCEPTS.dot(Concept.CONCEPT_ID).eq(Category.PHARMACEUTICAL_OR_BIOLOGICAL_PRODUCT.conceptId));
		String[] row = new String[] {"product", "isPrescribable","conceptIdentifier","type", "isSearchable", "prescribeAs" };
		csv.writeNext(row);
		try (ResultBatchIterator<Concept> iterator = query.batchIterator(context, 500)) {
			while (iterator.hasNext()) {
				List<Concept> batch = iterator.next();
				for (Concept c : batch) {
					Dmd.Product.productForConcept(c).ifPresent(p -> {
						row[0] = c.getPreferredDescription().getTerm();
						row[1] = String.valueOf(_productIsPrescribable(c, p));
						row[2] = c.getConceptId().toString();
						row[3] = p.abbreviation();
						row[4] = String.valueOf(_productIsSearchable(c, p));
						row[5] = _prescribingNotes(c,  p);
						csv.writeNext(row);
					});
				}
			}
		}
	} catch (IOException e) {
		e.printStackTrace();
		return CommandOutcome.failed(-1, e);
	}
	return CommandOutcome.succeeded();
}
 
开发者ID:wardle,项目名称:rsterminology,代码行数:31,代码来源:ExportDmdMain.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java JCSynchronized类代码示例发布时间:2022-05-22
下一篇:
Java JsRuntimeReplFactoryBuilder类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap