本文整理汇总了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);
}
示例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);
}
}
示例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);
}
示例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()));
}
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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();
}
示例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;
}
}
示例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();
}
示例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;
}
}
}
}
示例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();
}
}
示例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);
}
}