private boolean userContainsWithDataAuth(final User user) { return validateAuths(user.getDataAuths(), this.withDataAuth, true); }
boolean contains = false; for (User user : userdata) { // assuming userID is a number!! if(user.getUserId() == u.getUserId()) { contains = true; break; } }
public GafferResultCacheExporter(final Context context, final String jobId, final Graph resultCache, final String visibility, final Set<String> requiredOpAuths) { this.context = context; this.jobId = jobId; this.resultCache = resultCache; this.visibility = visibility; if (null == requiredOpAuths) { this.requiredOpAuths = CollectionUtil.treeSet(context.getUser().getUserId()); } else { this.requiredOpAuths = new TreeSet<>(requiredOpAuths); } userOpAuths = new HashSet<>(context.getUser().getOpAuths()); userOpAuths.add(context.getUser().getUserId()); }
@BindingAnnotation(UserBinder.UserBinderFactory.class) @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.PARAMETER}) public @interface UserBinder { public static class UserBinderFactory implements BinderFactory { @Override public Binder build(Annotation annotation) { return new Binder<UserBinder, User>() { @Override public void bind(SQLStatement<?> q, UserBinder bind, User arg) { q.bind("userId", arg.getUserId()); q.bind("uuid", arg.getUuid()); q.bind("openId", arg.getOpenId()); q.bind("givenName", arg.getGivenName()); // etc. } }; } } }
public String getList() throws JSONException { User dataUser =memberO.getMember(1); JSONObject jsonObject = new JSONObject(); jsonObject.put("name", dataUser.getUserName()); jsonObject.put("account", dataUser.getAccount()); jsonObject.put("edit", dataUser.getUserId()); jsonObject.put("delete", dataUser.getUserId()); JSONArray jsonArray = new JSONArray(); jsonArray.put(0, jsonObject); JSONObject topObject = new JSONObject(); topObject.put("data", jsonArray); System.out.println(topObject.toJSONString); System.out.println(jsonArray); String str = "{\"data\": [{\"name\": \""+dataUser.getUserName()+"\",\"account\": \""+dataUser.getAccount()+"\",\"edit\": \""+dataUser.getUserId()+"\",\"delete\": \""+dataUser.getUserId()+"\"}]}"; return str; }
public class UserDao { // you need to call your Singleton Connection class: Connection con = MyConnection.getInstanceOf(); // and then you write a method to update your object, here I'm updating a User Object: public void updateUser(User user) { try { String sql= "Update User set username='"+user.getUserName()+"',score='"+user.getScore()+"' where userid='"+user.getUserId()+"'"; Statement ste= con.createStatement(); ste.executeUpdate(sql); } catch (SQLException ex) { Logger.getLogger(UserDao.class.getName()).log(Level.SEVERE, null, ex); } }
if (null != user && null != user.getDataAuths()) { authorisations = new Authorizations(user.getDataAuths().toArray(new String[user.getDataAuths().size()])); } else { authorisations = new Authorizations(); .concat(view.getEntityGroups().stream(), view.getEdgeGroups().stream()) .map(g -> new org.apache.accumulo.core.util.Pair<>(new Text(g), (Text) null)) .collect(Collectors.toSet()); InputConfigurator.fetchColumns(AccumuloInputFormat.class, conf, columnFamilyColumnQualifierPairs); LOGGER.info("Updated configuration with column family/qualifiers of {}",
protected void runExampleNoResult(final Operation<?, Void> operation) { log("#### " + getMethodNameAsSentence(1) + "\n"); printJava(JavaSourceUtil.getRawJavaSnippet(getClass(), "example/example-graph", " " + getMethodName(1) + "() {", String.format("---%n"), "// ----")); printAsJson(operation); printOperationClass(operation); try { getGraph().execute(operation, new User("user01")); } catch (OperationException e) { throw new RuntimeException(e); } log(METHOD_DIVIDER); }
public Iterable<Entity> run() throws OperationException { final User user = new User("user01"); .build(); graph.execute(addOpChain, user); .build()) .build(); final Iterable<Edge> allEdges = graph.execute(getAllEdges, user); log("GET_A-B_EDGE_RESULT", edge.toString()); .addSeed(new EdgeSeed("A", "B", false)) .build(); final Iterable<Edge> edges = graph.execute(query, user); final Edge edge = edges.iterator().next(); final ReservoirItemsSketch<String> stringsSketch = ((ReservoirItemsUnion<String>) edge.getProperty("stringsSample")) .getResult(); final String[] samples = stringsSketch.getSamples(); final Iterable<Entity> entities = graph.execute(query2, user); final Entity entity = entities.iterator().next(); final ReservoirItemsSketch<String> neighboursSketch = ((ReservoirItemsUnion<String>) entity.getProperty("neighboursSample")) .getResult(); final String[] neighboursSample = neighboursSketch.getSamples();
public Iterable<Entity> run() throws OperationException { final User user = new User("user01"); .build(); graph.execute(addOpChain, user); final Iterable<Edge> edges = graph.execute(new GetAllEdges(), user); log("GET_ALL_EDGES_RESULT", edge.toString()); .build(); final CloseableIterable<Entity> allCardinalities = graph.execute(getAllCardinalities, user); log("\nAll cardinalities"); for (final Entity cardinality : allCardinalities) { final String edgeGroup = (cardinality.getProperty("edgeGroup")).toString(); log("ALL_CARDINALITIES_RESULT", "Vertex " + cardinality.getVertex() + " " + edgeGroup + ": " + ((HyperLogLogPlus) cardinality.getProperty("hllp")).cardinality());
final User user = new User("user01"); .build(); graph.execute(addOpChain, user); final CloseableIterable<? extends Element> edges = graph.execute(new GetAllElements(), user); .build(); final CloseableIterable<? extends Element> allCardinalities = graph.execute(getAllCardinalities, user); log("\nAll cardinalities"); for (final Element cardinality : allCardinalities) { final String edgeGroup = cardinality.getProperty("edgeGroup").toString(); log("ALL_CARDINALITIES_RESULT", "Vertex " + ((Entity) cardinality).getVertex() + " " + edgeGroup + ": " + ((HyperLogLogPlus) cardinality.getProperty("hllp")).cardinality()); for (final Element cardinality : allSummarisedCardinalities) { final String edgeGroup = cardinality.getProperty("edgeGroup").toString(); log("ALL_SUMMARISED_CARDINALITIES_RESULT", "Vertex " + ((Entity) cardinality).getVertex() + " " + edgeGroup + ": " + ((HyperLogLogPlus) cardinality.getProperty("hllp")).cardinality()); log("\nRoadUse edge cardinality at vertex 10:"); final String edgeGroup = (roadUse10Cardinality.getProperty("edgeGroup")).toString(); log("CARDINALITY_OF_10_RESULT", "Vertex " + ((Entity) roadUse10Cardinality).getVertex() + " " + edgeGroup + ": " + ((HyperLogLogPlus) roadUse10Cardinality.getProperty("hllp")).cardinality());
final User user = new User("user01"); .build(); graph.execute(addOpChain, user); final JobDetail initialJobDetail = graph.executeJob(job, user); final String jobId = initialJobDetail.getJobId(); final JobDetail jobDetail = graph.execute( new GetJobDetails.Builder() .jobId(jobId)
public Iterable<Entity> run() throws OperationException { final User user = new User("user01"); .build(); graph.execute(addOpChain, user); final Iterable<Entity> entities = graph.execute(get, user); for (final Entity entity : entities) { log("GET_ENTITIES", entity.toString()); final Iterable<Entity> allEntities2 = graph.execute(getAllEntities2, user); final Iterator<Entity> it = allEntities2.iterator(); final Entity entityDay1 = it.next(); final CompactSketch sketchDay1 = ((Union) entityDay1.getProperty("size")).getResult(); final Entity entityDay2 = it.next(); final CompactSketch sketchDay2 = ((Union) entityDay2.getProperty("size")).getResult(); final double estimateDay1 = sketchDay1.getEstimate(); final double estimateDay2 = sketchDay2.getEstimate();
public static void main(final String[] args) { if (args.length != 4) { System.err.println("Usage: " + RoadTrafficDataLoader.class.getSimpleName() + " <graphConfigFile> <schemaDir> <storePropsFile> <roadTrafficDataFile.csv>"); System.exit(1); } final String graphConfigFile = args[0]; final String schemaDir = args[1]; final String storePropertiesFile = args[2]; final String dataFile = args[3]; final GraphConfig config = new GraphConfig.Builder().json(new File(graphConfigFile).toPath()).build(); final Schema schema = Schema.fromJson(new File(schemaDir).toPath()); final StoreProperties storeProperties = StoreProperties.loadStoreProperties(storePropertiesFile); final Graph graph = new Graph.Builder() .config(config) .addSchemas(schema) .storeProperties(storeProperties) .build(); final User user = new User(); final RoadTrafficDataLoader dataLoader = new RoadTrafficDataLoader(graph, user); LOGGER.info("Loading data"); try { dataLoader.load(new File(dataFile)); LOGGER.info("Data has been loaded"); } catch (final Exception e) { LOGGER.info("Unable to load data: " + e.getMessage()); throw new RuntimeException("Unable to load data", e); } }
/** * The FederatedStore at time of initialisation, can set the auths required * to allow users to use custom {@link StoreProperties} outside the * scope of the {@link uk.gov.gchq.gaffer.store.library.GraphLibrary}. * * @param user the user needing validation for custom property usage. * @return boolean permission */ public boolean isLimitedToLibraryProperties(final User user) { return (null != this.customPropertiesAuths) && Collections.disjoint(user.getOpAuths(), this.customPropertiesAuths); }
public static void execute() { getListOfUsers(); getListOfCustomers(); for (int i=0;i<listUsers.size();i++) { User user = listUsers.remove(i); UserTO u = new UserTO(); Map<String, Boolean> map = new HashMap<>(); for (Customer customer : listCustomers) { if (customer.getCompanyName() == user.getCustomers(customer)) { map.put(customer.getCompanyName(), true); } else { map.put(customer.getCompanyName(), false); } } user.getUserId(); u.setUserId(user.getUserId()); u.setMap(map); listUsers.add(i,user); } }
/** * Checks the {@link OperationChain} is allowed to be executed by the user. * This is done by checking the user's auths against the auth scores getting the users maximum score limit value. * Then checking the operation score of all operations in the chain and comparing the total score value of the chain against a users maximum score limit. * If an operation cannot be executed then an {@link IllegalAccessError} is thrown. * * @param context the Context containing the user to authorise. * @param opChain the operation chain. */ @Override public void preExecute(final OperationChain<?> opChain, final Context context) { if (null != opChain) { Integer chainScore = scorer.getChainScore(opChain, context.getUser()); Integer maxAuthScore = scorer.getMaxUserAuthScore(context.getUser().getOpAuths()); if (chainScore > maxAuthScore) { throw new UnauthorisedException("The maximum score limit for user: " + context.getUser().toString() + " is " + maxAuthScore + ".\n" + "The requested operation chain exceeded this score limit."); } } }
protected void runExampleNoResult(final Operation operation, final String description) { log("#### " + getMethodNameAsSentence(1) + "\n"); if (StringUtils.isNotBlank(description)) { log(description + "\n"); } printMethodJavaSnippet(); printAsJson(operation); try { getGraph().execute(operation, new User("user01")); } catch (final OperationException e) { throw new RuntimeException(e); } log(METHOD_DIVIDER); }