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


Java IContext类代码示例

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


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

示例1: validateModule

import com.mendix.systemwideinterfaces.core.IContext; //导入依赖的package包/类
protected Object validateModule(IContext context, String moduleName) throws CoreException {
	this.activeModule.add(moduleName);

	if (!this.moduleMap.containsKey(moduleName)) {
		this.moduleMap.put(moduleName, null);

		IMendixObject obj = Core.instantiate(context, Module.getType());
		obj.setValue(context, Module.MemberNames.ModuleName.toString(), moduleName);

		if (this.allNewModules) {
			this.moduleMap.put(moduleName, obj);
			obj.setValue(context, Module.MemberNames.SynchronizeObjectsWithinModule.toString(), true);
		}

		Core.commit(context, obj);

	}

	return this.moduleMap.get(moduleName);
}
 
开发者ID:appronto,项目名称:RedisConnector,代码行数:21,代码来源:Builder.java

示例2: messageArrived

import com.mendix.systemwideinterfaces.core.IContext; //导入依赖的package包/类
@Override
public void messageArrived(String topic, MqttMessage mqttMessage) throws Exception {
    try {
        logger.info(String.format("messageArrived: %s, %s, %s", topic, new String(mqttMessage.getPayload()), client.getClientId()));
        IContext ctx = Core.createSystemContext();
        ISession session = ctx.getSession();
        MqttSubscription subscription = getSubscriptionForTopic(topic);
        if (subscription != null) {
            String microflow = subscription.getOnMessageMicroflow();
            logger.info(String.format("Calling onMessage microflow: %s, %s", microflow, client.getClientId()));
            final ImmutableMap map = ImmutableMap.of("Topic", topic, "Payload", new String(mqttMessage.getPayload()));
            logger.info("Parameter map: " + map);
            //Core.execute(ctx, microflow, true, map);
            Core.executeAsync(ctx, microflow, true, map);
        } else {
            logger.error(String.format("Cannot find microflow for message received on topic %s", topic));
        }
    } catch (Exception e) {
        logger.error(e);
    }
}
 
开发者ID:ako,项目名称:MqttClient,代码行数:22,代码来源:MxMqttCallback.java

示例3: firstWhere

import com.mendix.systemwideinterfaces.core.IContext; //导入依赖的package包/类
public static IMendixObject firstWhere(IContext c, String entityName,
		Object member, String value) throws CoreException
{
	List<IMendixObject> items = Core.retrieveXPathQuery(c, String.format("//%s[%s =  '%s']", entityName, member, value), 1, 0, new HashMap<String, String>());
	if (items == null || items.size() == 0)
		return null;
	return items.get(0);
}
 
开发者ID:appronto,项目名称:RedisConnector,代码行数:9,代码来源:ORM.java

示例4: copyAttributes

import com.mendix.systemwideinterfaces.core.IContext; //导入依赖的package包/类
public static void copyAttributes(IContext context, IMendixObject source, IMendixObject target)
{
	if (source == null)
		throw new IllegalStateException("source is null");
	if (target == null)
		throw new IllegalStateException("target is null");
	
	for(IMetaPrimitive e : target.getMetaObject().getMetaPrimitives()) {
		if (!source.hasMember(e.getName()))
			continue;
		if (e.isVirtual() || e.getType() == PrimitiveType.AutoNumber)
			continue;
		
		target.setValue(context, e.getName(), source.getValue(context, e.getName()));
	}
}
 
开发者ID:ako,项目名称:MqttClient,代码行数:17,代码来源:ORM.java

示例5: validateTokens

import com.mendix.systemwideinterfaces.core.IContext; //导入依赖的package包/类
public static List<IMendixObject> validateTokens(IContext context, String text, List<IMendixObject> tokenList) throws CoreException
{
	if (tokenList == null)
	{
		throw new CoreException("The given token list is empty.");
	}
	if (text == null)
	{
		throw new CoreException("The source text is empty.");
	}
	
	List<IMendixObject> missingTokens = new ArrayList<IMendixObject>();
	for (IMendixObject token : tokenList)
	{
		if( !isTokenPresent(context, text, token) )
			missingTokens.add(token);
	}

	return missingTokens;
}
 
开发者ID:appronto,项目名称:RedisConnector,代码行数:21,代码来源:TokenReplacer.java

示例6: cloneObject

import com.mendix.systemwideinterfaces.core.IContext; //导入依赖的package包/类
public static Boolean cloneObject(IContext c, IMendixObject source,
		IMendixObject target, Boolean withAssociations)
{
	Map<String, ? extends IMendixObjectMember<?>> members = source.getMembers(c);

	for(String key : members.keySet()) { 
		IMendixObjectMember<?> m = members.get(key);
		if (m.isVirtual())
			continue;
		if (m instanceof MendixAutoNumber)
			continue;
		if (withAssociations || ((!(m instanceof MendixObjectReference) && !(m instanceof MendixObjectReferenceSet)&& !(m instanceof MendixAutoNumber))))
			target.setValue(c, key, m.getValue(c));
	}
	return true;
}
 
开发者ID:ako,项目名称:MqttClient,代码行数:17,代码来源:ORM.java

示例7: updateConversationContext

import com.mendix.systemwideinterfaces.core.IContext; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private static Map<String, Object> updateConversationContext(IContext context, ConversationContext conversationContext, MessageResponse response) throws CoreException {
	deleteCurrentDialogStack(conversationContext);

	conversationContext.setConversationId(context, response.getContext().get("conversation_id").toString());
	Map<String, Object> responseContext = response.getContext();
	Map<String, Object> resposeSystemContext = (Map<String, Object>) responseContext.get("system");
	conversationContext.setDialogTurnCounter(new BigDecimal(resposeSystemContext.get("dialog_turn_counter").toString()));
	conversationContext.setDialogRequestCounter(new BigDecimal(resposeSystemContext.get("dialog_request_counter").toString()));

	List<String> dialogStack = (List<String>) resposeSystemContext.get("dialog_stack");
	for(String dialogNode : dialogStack){
		final IMendixObject dialogNodeObject = Core.instantiate(context, DialogNode.entityName );
		dialogNodeObject.setValue(context, DialogNode.MemberNames.Name.toString(), dialogNode);
		final List<IMendixIdentifier> conversationContextList = new ArrayList<IMendixIdentifier>();
		conversationContextList.add(conversationContext.getMendixObject().getId());
		dialogNodeObject.setValue(context, DialogNode.MemberNames.Dialog_Stack.toString(), conversationContextList);

		Core.commit(context, dialogNodeObject);
	}

	conversationContext.commit();
	return resposeSystemContext;
}
 
开发者ID:mendix,项目名称:IBM-Watson-Connector-Suite,代码行数:25,代码来源:ConversationService.java

示例8: sendInvite

import com.mendix.systemwideinterfaces.core.IContext; //导入依赖的package包/类
public static void sendInvite(IContext context, java.lang.String _environmentUUID, java.lang.String _environmentPassword, java.lang.String _roleUUID, java.lang.String _inviteeEmailAddress, java.lang.String _inviterEmailAddress)
{
	try
	{
		Map<java.lang.String, Object> params = new HashMap<java.lang.String, Object>();
		params.put("EnvironmentUUID", _environmentUUID);
		params.put("EnvironmentPassword", _environmentPassword);
		params.put("RoleUUID", _roleUUID);
		params.put("InviteeEmailAddress", _inviteeEmailAddress);
		params.put("InviterEmailAddress", _inviterEmailAddress);
		Core.execute(context, "InviteAPI.SendInvite", params);
	}
	catch (CoreException e)
	{
		throw new MendixRuntimeException(e);
	}
}
 
开发者ID:ako,项目名称:MqttClient,代码行数:18,代码来源:Microflows.java

示例9: getUserProfile

import com.mendix.systemwideinterfaces.core.IContext; //导入依赖的package包/类
public static profileservice.proxies.UserProfile getUserProfile(IContext context, java.lang.String _openID, java.lang.String _environmentUUID, java.lang.String _environmentPassword)
{
	try
	{
		Map<java.lang.String, Object> params = new HashMap<java.lang.String, Object>();
		params.put("OpenID", _openID);
		params.put("EnvironmentUUID", _environmentUUID);
		params.put("EnvironmentPassword", _environmentPassword);
		IMendixObject result = (IMendixObject)Core.execute(context, "ProfileService.GetUserProfile", params);
		return result == null ? null : profileservice.proxies.UserProfile.initialize(context, result);
	}
	catch (CoreException e)
	{
		throw new MendixRuntimeException(e);
	}
}
 
开发者ID:ako,项目名称:MqttClient,代码行数:17,代码来源:Microflows.java

示例10: translate

import com.mendix.systemwideinterfaces.core.IContext; //导入依赖的package包/类
public static IMendixObject translate(IContext context, Translation translation, String username, String password) throws MendixException, CoreException {
	LOGGER.debug("Executing Translate Connector...");

	service.setUsernameAndPassword(username, password);

	final Language source = getLanguage(translation.getTranslation_SourceLanguage().getCode());
	final Language target = getLanguage(translation.getTranslation_TargetLanguage().getCode());

	TranslationResult result;
	try {

		result = service.translate(translation.getText(), source, target).execute();
	} catch (Exception e) {
		LOGGER.error("Watson Service connection - Failed translating from" + source + " to " + target + " the text " + StringUtils.abbreviate(translation.getText(), 20), e);
		throw new MendixException(e);
	}

	translation.setWordCount(Long.valueOf(result.getWordCount()));
	translation.setCharacterCount(Long.valueOf(result.getCharacterCount()));
	translation.setOutput(result.getFirstTranslation());
	Core.commit(context, translation.getMendixObject());

	return translation.getMendixObject();
}
 
开发者ID:mendix,项目名称:IBM-Watson-Connector-Suite,代码行数:25,代码来源:LanguageTranslationService.java

示例11: findUser

import com.mendix.systemwideinterfaces.core.IContext; //导入依赖的package包/类
private static IUser findUser(IContext c, String openID) throws CoreException {
	List<IMendixObject> userList = Core.retrieveXPathQuery(c, String.format("//%s[%s='%s']", USER_ENTITY, USER_ENTITY_NAME, openID));
	
	if (userList.size() > 0) {
		IMendixObject userObject = userList.get(0);
		String username = userObject.getValue(c, DEFAULT_MENDIX_USERNAME_ATTRIBUTE);
		if (LOG.isTraceEnabled())
			LOG.trace("Getting System.User using username: '" + username + "'");
		
		return Core.getUser(c, username);
	} else {
		return null;
	}
}
 
开发者ID:mendix,项目名称:IBM-Watson-Connector-Suite,代码行数:15,代码来源:SessionInitializer.java

示例12: findAllTests

import com.mendix.systemwideinterfaces.core.IContext; //导入依赖的package包/类
public synchronized void findAllTests(IContext context) throws CoreException {
	/*
	 * Find modules
	 */
	Set<String> modules = new HashSet<String>();
	for(String name : Core.getMicroflowNames())
		modules.add(name.split("\\.")[0]);
	
	/*
	 * Update modules
	 */
	for(String module : modules) {
		TestSuite testSuite = XPath.create(context, TestSuite.class).findOrCreate(TestSuite.MemberNames.Module, module);
		updateUnitTestList(context, testSuite);
	}
	
	/*
	 * Remove all modules without tests
	 */
	XPath.create(context, TestSuite.class).not().hasReference(UnitTest.MemberNames.UnitTest_TestSuite, UnitTest.entityName).close().deleteAll();
}
 
开发者ID:ako,项目名称:MqttClient,代码行数:22,代码来源:TestManager.java

示例13: findOrCreateSynchronized

import com.mendix.systemwideinterfaces.core.IContext; //导入依赖的package包/类
public T findOrCreateSynchronized(Object... keysAndValues) throws CoreException, InterruptedException {
	T res = findFirst(keysAndValues);
	
	if (res != null) {
		return res;
	} else {
		synchronized (Core.getMetaObject(entity)) {
			IContext synchronizedContext = context.getSession().createContext().createSudoClone();
			try {
				synchronizedContext.startTransaction();
				res = createProxy(synchronizedContext, proxyClass, XPath.create(synchronizedContext, entity).findOrCreate(keysAndValues));
				synchronizedContext.endTransaction();
				return res;
			} catch (CoreException e) {
				if (synchronizedContext.isInTransaction()) {
					synchronizedContext.rollbackTransAction();
				}
				throw e;
			}
		}
	}
}
 
开发者ID:mendix,项目名称:database-connector,代码行数:23,代码来源:XPath.java

示例14: getCloneOfObject

import com.mendix.systemwideinterfaces.core.IContext; //导入依赖的package包/类
private static IMendixIdentifier getCloneOfObject(IContext ctx, IMendixObject src,
           List<String> toskip, List<String> tokeep, List<String> revAssoc,
           List<String> skipEntities, List<String> skipModules,
           Map<IMendixIdentifier, IMendixIdentifier> mappedObjects) throws CoreException
{
    String objType = src.getMetaObject().getName();
    String modName = src.getMetaObject().getModuleName();
    
    // if object is already being cloned, return ref to clone
    if (mappedObjects.containsKey(src.getId())) {
           return mappedObjects.get(src.getId());
       // if object should be skipped based on module or entity, return source object
       } else if (skipEntities.contains(objType) || skipModules.contains(modName)) {
           return src.getId();            
        // if not already being cloned, create clone
       } else { 
           IMendixObject clone = Core.instantiate(ctx, src.getType());
           duplicate(ctx, src, clone, toskip, tokeep, revAssoc, skipEntities, skipModules, mappedObjects);
           return clone.getId();               
       }
}
 
开发者ID:ako,项目名称:MqttClient,代码行数:22,代码来源:ORM.java

示例15: getRolesForOpenID

import com.mendix.systemwideinterfaces.core.IContext; //导入依赖的package包/类
public static java.util.List<permissionsapi.proxies.AppRole> getRolesForOpenID(IContext context, java.lang.String _openID, java.lang.String _environmentID, java.lang.String _environmentPassword)
{
	try
	{
		Map<java.lang.String, Object> params = new HashMap<java.lang.String, Object>();
		params.put("OpenID", _openID);
		params.put("EnvironmentID", _environmentID);
		params.put("EnvironmentPassword", _environmentPassword);
		java.util.List<IMendixObject> objs = Core.execute(context, "PermissionsAPI.GetRolesForOpenID", params);
		java.util.List<permissionsapi.proxies.AppRole> result = null;
		if (objs != null)
		{
			result = new java.util.ArrayList<permissionsapi.proxies.AppRole>();
			for (IMendixObject obj : objs)
				result.add(permissionsapi.proxies.AppRole.initialize(context, obj));
		}
		return result;
	}
	catch (CoreException e)
	{
		throw new MendixRuntimeException(e);
	}
}
 
开发者ID:ako,项目名称:MqttClient,代码行数:24,代码来源:Microflows.java


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