Search in sources :

Example 76 with Transaction

use of com.runwaysdk.dataaccess.transaction.Transaction in project geoprism-registry by terraframe.

the class MasterListVersion method updateRecord.

@Transaction
public void updateRecord(ServerGeoObjectIF object) {
    object.setDate(this.getForDate());
    // Delete tile cache
    TileCache.deleteTiles(this);
    MasterList masterlist = this.getMasterlist();
    MdBusinessDAO mdBusiness = MdBusinessDAO.get(this.getMdBusinessOid()).getBusinessDAO();
    Collection<Locale> locales = LocalizationFacade.getInstalledLocales();
    // Add the type ancestor fields
    ServerGeoObjectType type = ServerGeoObjectType.get(masterlist.getUniversal());
    Set<ServerHierarchyType> hierarchiesOfSubTypes = type.getHierarchiesOfSubTypes();
    Map<ServerHierarchyType, List<ServerGeoObjectType>> ancestorMap = masterlist.getAncestorMap(type);
    Collection<AttributeType> attributes = type.getAttributeMap().values();
    BusinessQuery query = new QueryFactory().businessQuery(mdBusiness.definesType());
    query.WHERE(query.aCharacter(DefaultAttribute.CODE.getName()).EQ(object.getCode()));
    List<Business> records = query.getIterator().getAll();
    for (Business record : records) {
        try {
            record.appLock();
            this.publish(object, record, attributes, ancestorMap, hierarchiesOfSubTypes, locales);
        } finally {
            record.unlock();
        }
    }
}
Also used : Locale(java.util.Locale) BusinessQuery(com.runwaysdk.business.BusinessQuery) ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) QueryFactory(com.runwaysdk.query.QueryFactory) MdBusinessDAO(com.runwaysdk.dataaccess.metadata.MdBusinessDAO) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) AttributeType(org.commongeoregistry.adapter.metadata.AttributeType) List(java.util.List) LinkedList(java.util.LinkedList) MdBusiness(com.runwaysdk.system.metadata.MdBusiness) Business(com.runwaysdk.business.Business) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 77 with Transaction

use of com.runwaysdk.dataaccess.transaction.Transaction in project geoprism-registry by terraframe.

the class UndirectedGraphType method delete.

@Override
@Transaction
public void delete() {
    MdEdge mdEdge = this.getMdEdge();
    super.delete();
    mdEdge.delete();
}
Also used : MdEdge(com.runwaysdk.system.metadata.MdEdge) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 78 with Transaction

use of com.runwaysdk.dataaccess.transaction.Transaction in project geoprism-registry by terraframe.

the class UserInfo method lockByUser.

@Transaction
public static JSONObject lockByUser(String userId) {
    GeoprismUser user = GeoprismUser.lock(userId);
    UserInfo info = UserInfo.getByUser(user);
    if (info != null) {
        info.lock();
    }
    return UserInfo.serialize(user, info);
}
Also used : GeoprismUser(net.geoprism.GeoprismUser) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 79 with Transaction

use of com.runwaysdk.dataaccess.transaction.Transaction in project geoprism-registry by terraframe.

the class RegistryAccountUtil method initiateInTrans.

@Transaction
public static void initiateInTrans(String sInvite, String roleIds) {
    if (roleIds == null || roleIds.length() == 0 || JsonParser.parseString(roleIds).getAsJsonArray().size() == 0) {
        // TODO : Better Error
        throw new AttributeValueException("You're attempting to invite a user with zero roles?", "");
    }
    JSONObject joInvite = new JSONObject(sInvite);
    String email = joInvite.getString("email");
    UserInvite invite = new UserInvite();
    invite.setEmail(email);
    UserInviteQuery query = new UserInviteQuery(new QueryFactory());
    query.WHERE(query.getEmail().EQi(invite.getEmail()));
    OIterator<? extends UserInvite> it = query.getIterator();
    while (it.hasNext()) {
        it.next().delete();
    }
    invite.setStartTime(new Date());
    invite.setToken(generateEncryptedToken(invite.getEmail()));
    invite.setRoleIds(roleIds);
    invite.apply();
    RegistryAccountUtil.sendEmail(invite, roleIds);
}
Also used : UserInvite(net.geoprism.account.UserInvite) QueryFactory(com.runwaysdk.query.QueryFactory) JSONObject(org.json.JSONObject) UserInviteQuery(net.geoprism.account.UserInviteQuery) AttributeValueException(com.runwaysdk.dataaccess.attributes.AttributeValueException) Date(java.util.Date) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 80 with Transaction

use of com.runwaysdk.dataaccess.transaction.Transaction in project geoprism-registry by terraframe.

the class RegistryAccountUtil method inviteCompleteInTrans.

@Transaction
private static void inviteCompleteInTrans(java.lang.String token, String json) {
    UserInviteQuery query = new UserInviteQuery(new QueryFactory());
    query.WHERE(query.getToken().EQ(token));
    OIterator<? extends UserInvite> reqIt = query.getIterator();
    UserInvite invite;
    if (reqIt.hasNext()) {
        invite = reqIt.next();
        invite.appLock();
    } else {
        throw new InvalidUserInviteToken();
    }
    if ((System.currentTimeMillis() - invite.getStartTime().getTime()) > (GeoprismProperties.getInviteUserTokenExpireTime() * 3600000)) {
        throw new InvalidUserInviteToken();
    }
    JsonObject account = JsonParser.parseString(json).getAsJsonObject();
    if (invite.getRoleIds().length() > 0) {
        JsonArray array = JsonParser.parseString(invite.getRoleIds()).getAsJsonArray();
        List<String> list = new LinkedList<String>();
        for (int i = 0; i < array.size(); i++) {
            list.add(array.get(i).getAsString());
        }
        UserInfo.applyUserWithRoles(account, list.toArray(new String[list.size()]), true);
    } else {
        UserInfo.applyUserWithRoles(account, new String[] {}, true);
    }
    invite.delete();
    logger.info("User [" + account.get(GeoprismUser.USERNAME) + "] has been created via a user invite.");
}
Also used : UserInvite(net.geoprism.account.UserInvite) JsonArray(com.google.gson.JsonArray) QueryFactory(com.runwaysdk.query.QueryFactory) InvalidUserInviteToken(net.geoprism.account.InvalidUserInviteToken) UserInviteQuery(net.geoprism.account.UserInviteQuery) JsonObject(com.google.gson.JsonObject) LinkedList(java.util.LinkedList) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Aggregations

Transaction (com.runwaysdk.dataaccess.transaction.Transaction)131 QueryFactory (com.runwaysdk.query.QueryFactory)29 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)27 JsonObject (com.google.gson.JsonObject)17 Date (java.util.Date)15 ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)15 MdBusinessDAO (com.runwaysdk.dataaccess.metadata.MdBusinessDAO)14 ServerGeoObjectIF (net.geoprism.registry.model.ServerGeoObjectIF)13 LinkedList (java.util.LinkedList)11 AttributeType (org.commongeoregistry.adapter.metadata.AttributeType)11 MdVertexDAOIF (com.runwaysdk.dataaccess.MdVertexDAOIF)10 ProgrammingErrorException (com.runwaysdk.dataaccess.ProgrammingErrorException)10 MdBusiness (com.runwaysdk.system.metadata.MdBusiness)10 List (java.util.List)10 ChangeRequest (net.geoprism.registry.action.ChangeRequest)10 VertexObject (com.runwaysdk.business.graph.VertexObject)8 IOException (java.io.IOException)8 GeoObjectImportConfiguration (net.geoprism.registry.io.GeoObjectImportConfiguration)8 LocalizedValue (org.commongeoregistry.adapter.dataaccess.LocalizedValue)8 JSONObject (org.json.JSONObject)8