private List<String> addDefaultConstraints(List<SQLDefaultConstraint> nns, boolean retrieveCD) throws InvalidObjectException, MetaException { List<String> nnNames = new ArrayList<>(); List<MConstraint> cstrs = new ArrayList<>(); String constraintName = null; for (int i = 0; i < nns.size(); i++) { final String catName = normalizeIdentifier(nns.get(i).getCatName()); final String tableDB = normalizeIdentifier(nns.get(i).getTable_db()); final String tableName = normalizeIdentifier(nns.get(i).getTable_name()); final String columnName = normalizeIdentifier(nns.get(i).getColumn_name()); final String ccName = nns.get(i).getDc_name(); boolean isEnable = nns.get(i).isEnable_cstr(); boolean isValidate = nns.get(i).isValidate_cstr(); boolean isRely = nns.get(i).isRely_cstr(); String constraintValue = nns.get(i).getDefault_value(); addConstraint(catName, tableDB, tableName, columnName, ccName, isEnable, isRely, isValidate, MConstraint.DEFAULT_CONSTRAINT, constraintValue, retrieveCD, nnNames, cstrs); } pm.makePersistentAll(cstrs); return nnNames; }
private List<String> addCheckConstraints(List<SQLCheckConstraint> cc, boolean retrieveCD) throws InvalidObjectException, MetaException { List<String> nnNames = new ArrayList<>(); List<MConstraint> cstrs = new ArrayList<>(); String constraintName = null; for (int i = 0; i < cc.size(); i++) { final String catName = normalizeIdentifier(cc.get(i).getCatName()); final String tableDB = normalizeIdentifier(cc.get(i).getTable_db()); final String tableName = normalizeIdentifier(cc.get(i).getTable_name()); final String columnName = cc.get(i).getColumn_name() == null? null : normalizeIdentifier(cc.get(i).getColumn_name()); final String ccName = cc.get(i).getDc_name(); boolean isEnable = cc.get(i).isEnable_cstr(); boolean isValidate = cc.get(i).isValidate_cstr(); boolean isRely = cc.get(i).isRely_cstr(); String constraintValue = cc.get(i).getCheck_expression(); addConstraint(catName, tableDB, tableName, columnName, ccName, isEnable, isRely, isValidate, MConstraint.CHECK_CONSTRAINT, constraintValue, retrieveCD, nnNames, cstrs); } pm.makePersistentAll(cstrs); return nnNames; }
cstrs.add(muk); pm.makePersistentAll(cstrs); return ukNames;
cstrs.add(muk); pm.makePersistentAll(cstrs); return nnNames;
mpks.add(mpk); pm.makePersistentAll(mpks); return pkNames;
pm.makePersistentAll(toPersist); pm.flush();
referencedKSignature = new StringBuilder(); pm.makePersistentAll(mpkfks);
pm.makePersistentAll(toPersist);
putPersistentPrivObjects(mtbl, toPersistPrivObjs, now, rolePrivs, PrincipalType.ROLE, "SQL"); pm.makePersistentAll(toPersistPrivObjs); commited = commitTransaction(); } finally {
pm.makePersistentAll(persistentObjs);
public Object doInJdo(PersistenceManager pm) throws JDOException { pm.makePersistentAll(entities); return null; } }, true);
public <T> T[] makePersistentAll(T... arg0) { return getPM().makePersistentAll(arg0); }
public <T> Collection<T> makePersistentAll(Collection<T> arg0) { return getPM().makePersistentAll(arg0); }
@ApiMethod(name = "insertRecordList") public RecordList insertRecordList(RecordList records) { PersistenceManager mgr = getPersistenceManager(); try { for(Record record : records.getRecords()){ if(record.getSyncTime() == null) record.setSyncTime(new Date()); } mgr.makePersistentAll(records.getRecords()); } finally { mgr.close(); } return records; }
private List<String> addDefaultConstraints(List<SQLDefaultConstraint> nns, boolean retrieveCD) throws InvalidObjectException, MetaException { List<String> nnNames = new ArrayList<>(); List<MConstraint> cstrs = new ArrayList<>(); String constraintName = null; for (int i = 0; i < nns.size(); i++) { final String catName = normalizeIdentifier(nns.get(i).getCatName()); final String tableDB = normalizeIdentifier(nns.get(i).getTable_db()); final String tableName = normalizeIdentifier(nns.get(i).getTable_name()); final String columnName = normalizeIdentifier(nns.get(i).getColumn_name()); final String ccName = nns.get(i).getDc_name(); boolean isEnable = nns.get(i).isEnable_cstr(); boolean isValidate = nns.get(i).isValidate_cstr(); boolean isRely = nns.get(i).isRely_cstr(); String constraintValue = nns.get(i).getDefault_value(); addConstraint(catName, tableDB, tableName, columnName, ccName, isEnable, isRely, isValidate, MConstraint.DEFAULT_CONSTRAINT, constraintValue, retrieveCD, nnNames, cstrs); } pm.makePersistentAll(cstrs); return nnNames; }
private List<String> addCheckConstraints(List<SQLCheckConstraint> cc, boolean retrieveCD) throws InvalidObjectException, MetaException { List<String> nnNames = new ArrayList<>(); List<MConstraint> cstrs = new ArrayList<>(); String constraintName = null; for (int i = 0; i < cc.size(); i++) { final String catName = normalizeIdentifier(cc.get(i).getCatName()); final String tableDB = normalizeIdentifier(cc.get(i).getTable_db()); final String tableName = normalizeIdentifier(cc.get(i).getTable_name()); final String columnName = cc.get(i).getColumn_name() == null? null : normalizeIdentifier(cc.get(i).getColumn_name()); final String ccName = cc.get(i).getDc_name(); boolean isEnable = cc.get(i).isEnable_cstr(); boolean isValidate = cc.get(i).isValidate_cstr(); boolean isRely = cc.get(i).isRely_cstr(); String constraintValue = cc.get(i).getCheck_expression(); addConstraint(catName, tableDB, tableName, columnName, ccName, isEnable, isRely, isValidate, MConstraint.CHECK_CONSTRAINT, constraintValue, retrieveCD, nnNames, cstrs); } pm.makePersistentAll(cstrs); return nnNames; }
private void alterSentryRoleAddUsersCore(PersistenceManager pm, String roleName, Set<String> userNames) throws SentryNoSuchObjectException { String trimmedRoleName = trimAndLower(roleName); MSentryRole role = getRole(pm, trimmedRoleName); if (role == null) { throw noSuchRole(trimmedRoleName); } Query query = pm.newQuery(MSentryUser.class); query.setFilter("this.userName == :userName"); query.setUnique(true); List<MSentryUser> users = Lists.newArrayList(); for (String userName : userNames) { userName = userName.trim(); MSentryUser user = (MSentryUser) query.execute(userName); if (user == null) { user = new MSentryUser(userName, System.currentTimeMillis(), Sets.newHashSet(role)); } user.appendRole(role); users.add(user); } pm.makePersistentAll(users); }
private void alterSentryRoleAddGroupsCore(PersistenceManager pm, String roleName, Set<TSentryGroup> groupNames) throws SentryNoSuchObjectException { // All role names are stored in lowercase. String lRoleName = trimAndLower(roleName); MSentryRole role = getRole(pm, lRoleName); if (role == null) { throw noSuchRole(lRoleName); } // Add the group to the specified role if it does not belong to the role yet. Query query = pm.newQuery(MSentryGroup.class); query.setFilter("this.groupName == :groupName"); query.setUnique(true); List<MSentryGroup> groups = Lists.newArrayList(); for (TSentryGroup tGroup : groupNames) { String groupName = tGroup.getGroupName().trim(); MSentryGroup group = (MSentryGroup) query.execute(groupName); if (group == null) { group = new MSentryGroup(groupName, System.currentTimeMillis(), Sets.newHashSet(role)); } group.appendRole(role); groups.add(group); } pm.makePersistentAll(groups); }
public void createTable(Table tbl) throws InvalidObjectException, MetaException { boolean commited = false; try { openTransaction(); MTable mtbl = convertToMTable(tbl); pm.makePersistent(mtbl); PrincipalPrivilegeSet principalPrivs = tbl.getPrivileges(); List<Object> toPersistPrivObjs = new ArrayList<Object>(); if (principalPrivs != null) { int now = (int)(System.currentTimeMillis()/1000); Map<String, List<PrivilegeGrantInfo>> userPrivs = principalPrivs.getUserPrivileges(); putPersistentPrivObjects(mtbl, toPersistPrivObjs, now, userPrivs, PrincipalType.USER); Map<String, List<PrivilegeGrantInfo>> groupPrivs = principalPrivs.getGroupPrivileges(); putPersistentPrivObjects(mtbl, toPersistPrivObjs, now, groupPrivs, PrincipalType.GROUP); Map<String, List<PrivilegeGrantInfo>> rolePrivs = principalPrivs.getRolePrivileges(); putPersistentPrivObjects(mtbl, toPersistPrivObjs, now, rolePrivs, PrincipalType.ROLE); } pm.makePersistentAll(toPersistPrivObjs); commited = commitTransaction(); } finally { if (!commited) { rollbackTransaction(); } } }
@Override public void createTable(Table tbl) throws InvalidObjectException, MetaException { boolean commited = false; try { openTransaction(); MTable mtbl = convertToMTable(tbl); pm.makePersistent(mtbl); PrincipalPrivilegeSet principalPrivs = tbl.getPrivileges(); List<Object> toPersistPrivObjs = new ArrayList<Object>(); if (principalPrivs != null) { int now = (int)(System.currentTimeMillis()/1000); Map<String, List<PrivilegeGrantInfo>> userPrivs = principalPrivs.getUserPrivileges(); putPersistentPrivObjects(mtbl, toPersistPrivObjs, now, userPrivs, PrincipalType.USER); Map<String, List<PrivilegeGrantInfo>> groupPrivs = principalPrivs.getGroupPrivileges(); putPersistentPrivObjects(mtbl, toPersistPrivObjs, now, groupPrivs, PrincipalType.GROUP); Map<String, List<PrivilegeGrantInfo>> rolePrivs = principalPrivs.getRolePrivileges(); putPersistentPrivObjects(mtbl, toPersistPrivObjs, now, rolePrivs, PrincipalType.ROLE); } pm.makePersistentAll(toPersistPrivObjs); commited = commitTransaction(); } finally { if (!commited) { rollbackTransaction(); } } }