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


Java ContentInstance类代码示例

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


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

示例1: doRetrieve

import org.eclipse.om2m.commons.resource.ContentInstance; //导入依赖的package包/类
/**
 * Generic do retrieve operation
 * @param request
 * @return response
 */
@Override
public ResponsePrimitive doRetrieve(RequestPrimitive request) {
	// create the response primitive
	ResponsePrimitive response = new ResponsePrimitive(request);

	// check existence of the resource
	ContentInstanceEntity cinEntity = dbs.getDAOFactory().getContentInstanceDAO().find(transaction, request.getTargetId());
	if (cinEntity == null) {
		throw new ResourceNotFoundException("Resource not found");
	}

	// check authorization
	List<AccessControlPolicyEntity> acpList = cinEntity.getAcpListFromParent();
	checkACP(acpList, request.getFrom(), request.getOperation());
	

	// mapping the entity with the exchange resource
	ContentInstance cin = EntityMapperFactory.getContentInstanceMapper().
			mapEntityToResource(cinEntity, request);
	response.setContent(cin);

	response.setResponseStatusCode(ResponseStatusCode.OK); 
	// return the completed response
	return response;
}
 
开发者ID:HPCC-Cloud-Computing,项目名称:IoT,代码行数:31,代码来源:ContentInstanceController.java

示例2: mapAttributes

import org.eclipse.om2m.commons.resource.ContentInstance; //导入依赖的package包/类
@Override
protected void mapAttributes(ContentInstanceEntity entity,
		ContentInstance resource) {
	resource.setContent(entity.getContent());
	resource.setExpirationTime(entity.getExpirationTime());
	resource.setContentInfo(entity.getContentInfo());
	resource.setContentSize(BigInteger.valueOf(entity.getByteSize()));
	resource.setCreator(entity.getCreator());
	resource.setOntologyRef(entity.getOntologyRef());
	resource.setStateTag(entity.getStateTag());
	if (!entity.getAnnouncedAttribute().isEmpty()) {
		resource.getAnnouncedAttribute().addAll(
				entity.getAnnouncedAttribute());
	}
	if (!entity.getAnnounceTo().isEmpty()) {
		resource.getAnnounceTo().addAll(entity.getAnnounceTo());
	}
}
 
开发者ID:HPCC-Cloud-Computing,项目名称:IoT,代码行数:19,代码来源:ContentInstanceMapper.java

示例3: mapChildResources

import org.eclipse.om2m.commons.resource.ContentInstance; //导入依赖的package包/类
@Override
protected void mapChildResources(ContainerEntity entity, Container resource) {
	// add child ref contentInstance
	for (ContentInstanceEntity cin : entity.getChildContentInstances()) {
		ContentInstance cinRes = new ContentInstanceMapper().mapEntityToResource(cin, ResultContent.ATTRIBUTES);
		resource.getContentInstanceOrContainerOrSubscription().add(cinRes);
	}

	// add child ref subscription
	for (SubscriptionEntity sub : entity.getSubscriptions()){
		Subscription subRes = new SubscriptionMapper().mapEntityToResource(sub, ResultContent.ATTRIBUTES);
		resource.getContentInstanceOrContainerOrSubscription().add(subRes);
	}
	
	
	// add child ref with containers
	for (ContainerEntity childCont : entity.getChildContainers()) {
		Container cnt = new ContainerMapper().mapEntityToResource(childCont, ResultContent.ATTRIBUTES);
		resource.getContentInstanceOrContainerOrSubscription().add(cnt);
	}
}
 
开发者ID:HPCC-Cloud-Computing,项目名称:IoT,代码行数:22,代码来源:ContainerMapper.java

示例4: createLampAll

import org.eclipse.om2m.commons.resource.ContentInstance; //导入依赖的package包/类
/**
 * Create the LAMP_ALL container
 * @param poa
 */
private static void createLampAll(String poa) {
	// Creation of the LAMP_ALL container
	AE ae = new AE();
	ae.setRequestReachability(true);
	ae.getPointOfAccess().add(poa);
	ae.setAppID("LAMP_ALL");
	ResponsePrimitive response = RequestSender.createAE(ae, "LAMP_ALL");

	// Create descriptor container if not yet created
	if(response.getResponseStatusCode().equals(ResponseStatusCode.CREATED)){
		// Creation of the DESCRIPTOR container
		Container cnt = new Container();
		cnt.setMaxNrOfInstances(BigInteger.valueOf(10));
		RequestSender.createContainer(SampleConstants.CSE_PREFIX + "/" + "LAMP_ALL", SampleConstants.DESC, cnt);

		// Create the description
		ContentInstance cin = new ContentInstance();
		cin.setContent(ObixUtil.createLampAllDescriptor());
		cin.setContentInfo(MimeMediaType.OBIX);
		RequestSender.createContentInstance(SampleConstants.CSE_PREFIX + "/" + "LAMP_ALL" + "/" + SampleConstants.DESC, null, cin);
	}
}
 
开发者ID:HPCC-Cloud-Computing,项目名称:IoT,代码行数:27,代码来源:LifeCycleManager.java

示例5: createD10404Resources

import org.eclipse.om2m.commons.resource.ContentInstance; //导入依赖的package包/类
public void createD10404Resources(String appId, String spo2Value, String pulserateValue, String aPoCPath){
	// Create the Application resource
    ResponseConfirm response = SCL.doRequest(new RequestIndication(METHOD_CREATE,SCLID+"/applications",REQENTITY,new Application(appId,aPoCPath)));
    // Create Application sub-resources only if application not yet created
    if(response.getStatusCode().equals(StatusCode.STATUS_CREATED)) {
        // Create DESCRIPTOR container sub-resource
        SCL.doRequest(new RequestIndication(METHOD_CREATE,SCLID+"/applications/"+appId+"/containers",REQENTITY,new Container(DESC)));
        // Create STATE container sub-resource
        SCL.doRequest(new RequestIndication(METHOD_CREATE,SCLID+"/applications/"+appId+"/containers",REQENTITY,new Container(DATA)));

        String content, targetID;
        // Create DESCRIPTION contentInstance on the DESCRIPTOR container resource
        content = D10404.getDescriptorRep(SCLID, appId, DATA);
        targetID= SCLID+"/applications/"+appId+"/containers/"+DESC+"/contentInstances";
        SCL.doRequest(new RequestIndication(METHOD_CREATE,targetID,REQENTITY,new ContentInstance(content.getBytes())));

        // Create initial contentInstance on the STATE container resource
        content = D10404.getStateRep(appId, spo2Value, pulserateValue, "");
        targetID = SCLID+"/applications/"+appId+"/containers/"+DATA+"/contentInstances";
        SCL.doRequest(new RequestIndication(METHOD_CREATE,targetID,REQENTITY,new ContentInstance(content.getBytes())));
    }
}
 
开发者ID:AINLAB,项目名称:OHP-M2M,代码行数:23,代码来源:D10404Monitor.java

示例6: onLoad

import org.eclipse.om2m.commons.resource.ContentInstance; //导入依赖的package包/类
@Override
public void onLoad(CoapResponse response) {
	// TODO Auto-generated method stub
	String content, targetID, spo2value, pulseratevalue;
	String message = response.getResponseText();
	String[] buf = message.split("OBX");
	
	
	String[] spo2buf = buf[buf.length-2].split("\\|");
	spo2value = spo2buf[spo2buf.length-2];
	String[] pulsebuf = buf[buf.length-1].split("\\|");
	pulseratevalue = pulsebuf[pulsebuf.length-2];
	
	
	content = D10404.getStateRep(D10404.TYPE, spo2value, pulseratevalue, message);
	targetID = SCLID+"/applications/"+D10404.TYPE+"/containers/"+DATA+"/contentInstances";
          SCL.doRequest(new RequestIndication(METHOD_CREATE,targetID,REQENTITY,new ContentInstance(content.getBytes())));
}
 
开发者ID:AINLAB,项目名称:OHP-M2M,代码行数:19,代码来源:D10404Monitor.java

示例7: test7ContentInstanceGetAll

import org.eclipse.om2m.commons.resource.ContentInstance; //导入依赖的package包/类
/**
 * Test5 content instance get all.
 */
@Test
public void test7ContentInstanceGetAll() {
	LOGGER.info("\t***************** begin test *****************");

	// parent container of the future contentInstance
	Container container = new Container("MyContainerId2");
	// Parent application of the container
	Application myApp = new Application("MyApp" + APP_ID_TEST);
	container.setApplication(myApp);

	ContentInstanceManager contentInstanceManager = Om2mManagersFactorty.getManager(Om2mManagersFactorty.CONTENT_INSTANCE_MANAGER);

	List<ContentInstance> contentInstances = contentInstanceManager.getAll(container);

	LOGGER.info("is the contentInstance list null ? : " + (contentInstances == null));
	LOGGER.info("is the contentInstance list empty ? : " + contentInstances.isEmpty());

	Assert.assertNotEquals(null, contentInstances);
	Assert.assertFalse("Must be false (is the contentInstance list empty ?)", contentInstances.isEmpty());

	LOGGER.info("List of contentInstance >");
	for (ContentInstance ci : contentInstances) {
		System.out.println("CI> " + ci.getValueAsString() + " // " + ci.toString());
	}
}
 
开发者ID:BeliliFahem,项目名称:om2m-java-client-api,代码行数:29,代码来源:Om2mManagerTest.java

示例8: doRetrieve

import org.eclipse.om2m.commons.resource.ContentInstance; //导入依赖的package包/类
@Override
public ResponsePrimitive doRetrieve(RequestPrimitive request) {
	// Creating the response primitive
	ResponsePrimitive response = new ResponsePrimitive(request);

	// Check existence of the resource
	ContainerEntity containerEntity = dbs.getDAOFactory().getContainerDAO().find(transaction, request.getTargetId());
	if (containerEntity == null) {
		throw new ResourceNotFoundException("Resource not found");
	}

	// if resource exists, check authorization
	// retrieve 
	List<AccessControlPolicyEntity> acpList = containerEntity.getAccessControlPolicies();
	checkACP(acpList, request.getFrom(), request.getOperation());

	ContentInstanceEntity cinEntity = null;
	if (containerEntity.getChildContentInstances().isEmpty()) {
		throw new ResourceNotFoundException("Resource not found");
	}
	switch(this.policy){
	case LATEST:
		cinEntity = containerEntity.getChildContentInstances().get(
				containerEntity.getChildContentInstances().size()-1);
		break;
	case OLDEST:
		cinEntity = containerEntity.getChildContentInstances().get(0);
		break;
	default:
		break;
	}

	// mapping the entity with the exchange resource
	ContentInstance cin = EntityMapperFactory.getContentInstanceMapper().mapEntityToResource(cinEntity, request);		
	response.setContent(cin);
	response.setResponseStatusCode(ResponseStatusCode.OK);
	return response;
}
 
开发者ID:HPCC-Cloud-Computing,项目名称:IoT,代码行数:39,代码来源:LatestOldestController.java

示例9: setLampState

import org.eclipse.om2m.commons.resource.ContentInstance; //导入依赖的package包/类
public static void setLampState(String lampId, boolean value){
	// Set the value in the "real world" model
	SampleModel.setLampState(lampId, value);
	// Send the information to the CSE
	String targetID = SampleConstants.CSE_PREFIX + "/" + lampId + "/" + SampleConstants.DATA;
	ContentInstance cin = new ContentInstance();
	cin.setContent(ObixUtil.getStateRep(lampId, value));
	cin.setContentInfo(MimeMediaType.OBIX + ":" + MimeMediaType.ENCOD_PLAIN);
	RequestSender.createContentInstance(targetID, null, cin);
}
 
开发者ID:HPCC-Cloud-Computing,项目名称:IoT,代码行数:11,代码来源:SampleController.java

示例10: createSensorResources

import org.eclipse.om2m.commons.resource.ContentInstance; //导入依赖的package包/类
public void createSensorResources(String sensorId, int type) {
	String targetId, content;

	targetId = "/" + CSE_ID + "/" + CSE_NAME;
	AE ae = new AE();
	ae.setRequestReachability(true);
	ae.setAppID(ipeId);
	ae.getPointOfAccess().add(ipeId);
	ResponsePrimitive response = RequestSender.createAE(ae, sensorId);

	if (response.getResponseStatusCode().equals(ResponseStatusCode.CREATED)) {
		targetId = "/" + CSE_ID + "/" + CSE_NAME + "/" + sensorId;
		Container cnt = new Container();
		cnt.setMaxNrOfInstances(BigInteger.valueOf(10));
		// Create the DESCRIPTOR container
		RequestSender.createContainer(targetId, DESCRIPTOR, cnt);

		// Create the DATA container
		RequestSender.createContainer(targetId, DATA, cnt);

		// Create the description contentInstance
		content = ObixUtil.getSensorDescriptorRep(sensorId, ipeId);
		targetId = "/" + CSE_ID + "/" + CSE_NAME + "/" + sensorId + "/"
				+ DESCRIPTOR;
		ContentInstance cin = new ContentInstance();
		cin.setContent(content);
		cin.setContentInfo(MimeMediaType.OBIX);
		RequestSender.createContentInstance(targetId, cin);
	}
}
 
开发者ID:HPCC-Cloud-Computing,项目名称:IoT,代码行数:31,代码来源:Monitor.java

示例11: createDataContentInstance

import org.eclipse.om2m.commons.resource.ContentInstance; //导入依赖的package包/类
public static void createDataContentInstance(int type, String sensorId, String clusterId){
	// Simulate a random measurement of the sensor
	int sensorValue = 10 + (int) (Math.random() * 100);

	// Create the data contentInstance
	String content = ObixUtil.getSensorDataRep(sensorValue, type, sensorId, ipeId, clusterId);
	String targetId = "/" + CSE_ID + "/" + CSE_NAME + "/"
			+ sensorId + "/" + DATA;
	ContentInstance cin = new ContentInstance();
	cin.setContent(content);
	cin.setContentInfo(MimeMediaType.OBIX);
	RequestSender.createContentInstance(targetId, cin);		
}
 
开发者ID:HPCC-Cloud-Computing,项目名称:IoT,代码行数:14,代码来源:Monitor.java

示例12: createSubDataContentInstance

import org.eclipse.om2m.commons.resource.ContentInstance; //导入依赖的package包/类
public static void createSubDataContentInstance(int type, String sensorId){
	// Simulate a random measurement of the sensor
	int sensorValue = 10 + (int) (Math.random() * 100);

	// Create the data contentInstance
	String content = ObixUtil.getDataSubscriber();
	String targetId = "/" + CSE_ID + "/" + CSE_NAME + "/"
			+ sensorId + "/" + DATA;
	ContentInstance cin = new ContentInstance();
	cin.setContent(content);
	cin.setContentInfo(MimeMediaType.XML);
	RequestSender.createContentInstanceXML(targetId, "SUBSCRIPTION", cin, ResourceType.SUBSCRIPTION);		
}
 
开发者ID:HPCC-Cloud-Computing,项目名称:IoT,代码行数:14,代码来源:Monitor.java

示例13: createSensorResources

import org.eclipse.om2m.commons.resource.ContentInstance; //导入依赖的package包/类
public void createSensorResources(String sensorId, String type) {
	String targetId, content;

	targetId = "/" + CSE_ID + "/" + CSE_NAME;
	AE ae = new AE();
	ae.setRequestReachability(true);
	ae.setAppID(ipeId);
	ae.getPointOfAccess().add(ipeId);
	ResponsePrimitive response = RequestSender.createAE(ae, sensorId);

	if (response.getResponseStatusCode().equals(ResponseStatusCode.CREATED)) {
		targetId = "/" + CSE_ID + "/" + CSE_NAME + "/" + sensorId;
		Container cnt = new Container();
		cnt.setMaxNrOfInstances(BigInteger.valueOf(10));
		// Create the DESCRIPTOR container
		RequestSender.createContainer(targetId, DESCRIPTOR, cnt);

		// Create the DATA container
		RequestSender.createContainer(targetId, DATA, cnt);

		// Create the description contentInstance
		content = ObixUtil.getSensorDescriptorRep(sensorId, ipeId);
		targetId = "/" + CSE_ID + "/" + CSE_NAME + "/" + sensorId + "/"
				+ DESCRIPTOR;
		ContentInstance cin = new ContentInstance();
		cin.setContent(content);
		cin.setContentInfo(MimeMediaType.OBIX);
		RequestSender.createContentInstance(targetId, cin);
	}
}
 
开发者ID:HPCC-Cloud-Computing,项目名称:IoT,代码行数:31,代码来源:Monitor.java

示例14: createDataContentInstance

import org.eclipse.om2m.commons.resource.ContentInstance; //导入依赖的package包/类
public static void createDataContentInstance(SensorDataItem sensorItem){
	// Create the data contentInstance
	String content = ObixUtil.convertSensorDataRep(sensorItem);
	String targetId = "/" + CSE_ID + "/" + CSE_NAME + "/"
			+ sensorItem.mSensorId + "/" + DATA;
	ContentInstance cin = new ContentInstance();
	cin.setContent(content);
	cin.setContentInfo(MimeMediaType.OBIX);
	RequestSender.createContentInstance(targetId, cin);		
}
 
开发者ID:HPCC-Cloud-Computing,项目名称:IoT,代码行数:11,代码来源:Monitor.java

示例15: createBPMResources

import org.eclipse.om2m.commons.resource.ContentInstance; //导入依赖的package包/类
public void createBPMResources() {
	String targetId, content;

	// Create the COAP_BLOODPRESURE application
	targetId = sclId + "/applications";

	ResponseConfirm response = core.doRequest(new RequestIndication(
			"CREATE", targetId, reqEntity,
			new Application(sensorId, tempId)));
	// get ACK from SCL means the Application created
	if (response.getStatusCode().equals(StatusCode.STATUS_CREATED)) {
		// Create the "DESCRIPTOR" container
		targetId = sclId + "/applications/" + sensorId + "/containers";
		core.doRequest(new RequestIndication("CREATE", targetId, reqEntity,
				new Container("DESCRIPTOR")));
		// Create the "DATA" container
		core.doRequest(new RequestIndication("CREATE", targetId, reqEntity,
				new Container("DATA")));

		// Create the description contentInstance
		content = Spo2Device.getDescriptiorRep(sclId, sensorId, tempId);
		targetId = sclId + "/applications/" + sensorId
				+ "/containers/DESCRIPTOR/contentInstances";
		core.doRequest(new RequestIndication("CREATE", targetId, reqEntity,
				new ContentInstance(content.getBytes())));

		// Create the data contentInstance
		content = Spo2Device.getDIMRep(sensorId, null);
		targetId = sclId + "/applications/" + sensorId
				+ "/containers/DATA/contentInstances";
		core.doRequest(new RequestIndication("CREATE", targetId, reqEntity,
				new ContentInstance(content.getBytes())));
	}
}
 
开发者ID:AINLAB,项目名称:OHP-M2M,代码行数:35,代码来源:Spo2Monitor.java


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