• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java SchemaViolationException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: removeUserSchema

import javax.naming.directory.SchemaViolationException; //导入依赖的package包/类
/**
 * Mock a managed LDAP schema violation
 */
@Test
public void removeUserSchema() {
	thrown.expect(ValidationJsonException.class);
	thrown.expect(MatcherUtil.validationMatcher("groups", "last-member-of-group"));
	final GroupLdapRepository groupRepository = new GroupLdapRepository() {
		@Override
		public GroupOrg findById(final String name) {
			// The group has only the user user we want to remove
			return new GroupOrg("dc=" + name, name, Collections.singleton("flast1"));
		}

	};
	groupRepository.setLdapCacheRepository(Mockito.mock(LdapCacheRepository.class));

	final LdapTemplate ldapTemplate = Mockito.mock(LdapTemplate.class);
	groupRepository.setTemplate(ldapTemplate);
	Mockito.doThrow(new org.springframework.ldap.SchemaViolationException(new SchemaViolationException("any"))).when(ldapTemplate)
			.modifyAttributes(ArgumentMatchers.any(LdapName.class), ArgumentMatchers.any());
	removeUser(groupRepository);
}
 
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:24,代码来源:GroupLdapRepositoryTest.java


示例2: rename

import javax.naming.directory.SchemaViolationException; //导入依赖的package包/类
@Override
public void rename(Name nOld, Name nNew) throws NamingException {
    if (nOld == null || nNew == null) {
        throw new NullPointerException();
    }

    if (nOld.size() == 0 || nNew.size() == 0) {
        // ldap.3A=Can't rename empty name
        throw new InvalidNameException(Messages.getString("ldap.3A")); //$NON-NLS-1$
    }

    if (nOld.size() > 1 || nNew.size() > 1) {
        // ldap.3B=Can't rename across contexts
        throw new InvalidNameException(Messages.getString("ldap.3B")); //$NON-NLS-1$
    }
    // ldap.39=Can't rename schema
    throw new SchemaViolationException(Messages.getString("ldap.39")); //$NON-NLS-1$
}
 
开发者ID:shannah,项目名称:cn1,代码行数:19,代码来源:LdapSchemaContextImpl.java


示例3: executeOperation

import javax.naming.directory.SchemaViolationException; //导入依赖的package包/类
@Override
public void executeOperation(final LdbcShortQuery4MessageContent operation,TitanFTMDb.BasicDbConnectionState dbConnectionState,ResultReporter resultReporter) throws DbException {
    long mid = operation.messageId();
    TitanFTMDb.BasicClient client = dbConnectionState.client();
    Vertex m;
    try {
        logger.debug("Short Query 4 called on message id: {}", mid);
        m = client.getVertex(mid, "Comment");
        if (m==null)
            m = client.getVertex(mid, "Post");

        String content = m.getProperty("content");
        if (content.length() == 0)
            content = m.getProperty("imageFile");
        LdbcShortQuery4MessageContentResult res = new LdbcShortQuery4MessageContentResult(
                content,(Long)m.getProperty("creationDate"));

        resultReporter.report(1, res, operation);
    } catch (SchemaViolationException e) {
    e.printStackTrace();
    resultReporter.report(-1, null, operation);
}

}
 
开发者ID:ldbc,项目名称:ldbc_snb_implementations,代码行数:25,代码来源:LdbcShortQuery4Handler.java


示例4: getVertices

import javax.naming.directory.SchemaViolationException; //导入依赖的package包/类
/**
 * Gets the specified vertices or null if no such vertex is found
 *
 * @param label     vertex type label
 * @param limit     int value limiting the result. use Integer.MAX_VALUE for unlimited
 * @param pValueMap PropertyKey->Value map
 * @return the specified vertices or null if no such vertex is found
 */
public Iterable<Vertex> getVertices(String label, Map<String, String> pValueMap, int limit) throws SchemaViolationException {
    Integer suffix = s.getVertexTypes().get(label);
    Set<Vertex> res = new HashSet<>();
    if (suffix == null)
        throw new SchemaViolationException(label + " vertex type is not defined in the schema for " + s.getClass().getSimpleName());
    GraphQuery gq = g.query();
    for (String property : pValueMap.keySet())
        gq = gq.has(property, pValueMap.get(property));
    if (limit != Integer.MAX_VALUE)
        gq = gq.limit(limit);

    for (Vertex v : gq.vertices())
        if ((((Long) v.getId()) % mult) == suffix)
            res.add(v);

    return res;
}
 
开发者ID:ldbc,项目名称:ldbc_snb_implementations,代码行数:26,代码来源:TitanFTMDb.java


示例5: executeOperation

import javax.naming.directory.SchemaViolationException; //导入依赖的package包/类
@Override
public void executeOperation(LdbcUpdate5AddForumMembership operation, TitanFTMDb.BasicDbConnectionState dbConnectionState, ResultReporter reporter) throws DbException {

    TitanFTMDb.BasicClient client = dbConnectionState.client();

    try {
        Vertex forum = client.getVertex(operation.forumId(), "Forum");
        Vertex person = client.getVertex(operation.personId(), "Person");
        if (forum==null)
            logger.error("Forum membership requested for nonexistent forum id {}", operation.forumId());
        if (person==null)
            logger.error("Forum membership requested for nonexistent person {}", operation.personId());

        Map<String, Object> props = new HashMap<>(1);
        props.put("joinDate", operation.joinDate().getTime());
        client.addEdge(forum, person, "hasMember", props);

    } catch (SchemaViolationException e) {
        logger.error("invalid vertex label requested by query update");
        e.printStackTrace();
    }

    reporter.report(0, LdbcNoResult.INSTANCE,operation);
}
 
开发者ID:ldbc,项目名称:ldbc_snb_implementations,代码行数:25,代码来源:LdbcQueryU5Handler.java


示例6: executeOperation

import javax.naming.directory.SchemaViolationException; //导入依赖的package包/类
@Override
public void executeOperation(LdbcUpdate8AddFriendship operation, TitanFTMDb.BasicDbConnectionState dbConnectionState, ResultReporter reporter) throws DbException {

    TitanFTMDb.BasicClient client = dbConnectionState.client();
    try {

        Map<String, Object> props = new HashMap<>(1);
        props.put("creationDate", operation.creationDate().getTime());
        Vertex person = client.getVertex(operation.person1Id(), "Person");
        Vertex friend = client.getVertex(operation.person2Id(), "Person");
        client.addEdge(person, friend, "knows", props);

    } catch (SchemaViolationException e) {
        logger.error("invalid vertex label requested by query update");
        e.printStackTrace();
    }

    reporter.report(0, LdbcNoResult.INSTANCE, operation);
}
 
开发者ID:ldbc,项目名称:ldbc_snb_implementations,代码行数:20,代码来源:LdbcQueryU8Handler.java


示例7: executeOperation

import javax.naming.directory.SchemaViolationException; //导入依赖的package包/类
@Override
public void executeOperation(LdbcUpdate2AddPostLike operation, TitanFTMDb.BasicDbConnectionState dbConnectionState, ResultReporter reporter) throws DbException {

    TitanFTMDb.BasicClient client = dbConnectionState.client();

    try {
        Vertex person = client.getVertex(operation.personId(), "Person");
        Vertex post = client.getVertex(operation.postId(), "Post");
        Map<String, Object> props = new HashMap<>(1);
        props.put("creationDate", operation.creationDate().getTime());
        client.addEdge(person, post, "likes", props);

    } catch (SchemaViolationException e) {
        logger.error("invalid vertex label requested by query update");
        e.printStackTrace();
    }

    reporter.report(0, LdbcNoResult.INSTANCE,operation);
}
 
开发者ID:ldbc,项目名称:ldbc_snb_implementations,代码行数:20,代码来源:LdbcQueryU2Handler.java


示例8: getFoF

import javax.naming.directory.SchemaViolationException; //导入依赖的package包/类
/**
 * Given a person, returns the set of friends and friends of friends
 * , excluding that person
 *
 * @param rootId personID to start from
 * @param client TitanFTMDb.BasicClient to use for root retrieval
 * @return Set<Vertex> of the persons friends and their friends
 */
public Set<Vertex> getFoF(long rootId, TitanFTMDb.BasicClient client) {
    Set<Vertex> res = new HashSet<>();
    Vertex root = null;
    try {
        root = client.getVertex(rootId, "Person");
    } catch (SchemaViolationException e) {
        e.printStackTrace();
    }

    GremlinPipeline<Vertex, Vertex> gp = (new GremlinPipeline<Vertex, Vertex>(root));
    gp.out("knows").aggregate(res)
            .out("knows").aggregate(res).iterate();
    res.remove(root);
    return res;
}
 
开发者ID:ldbc,项目名称:ldbc_snb_implementations,代码行数:24,代码来源:QueryUtils.java


示例9: executeOperation

import javax.naming.directory.SchemaViolationException; //导入依赖的package包/类
@Override
public void executeOperation(final LdbcShortQuery1PersonProfile operation,TitanFTMDb.BasicDbConnectionState dbConnectionState,ResultReporter resultReporter) throws DbException {
    List<LdbcQuery1Result> result = new ArrayList<>();
    long person_id = operation.personId();
    TitanFTMDb.BasicClient client = dbConnectionState.client();
    final Vertex root;
    try {
        root = client.getVertex(person_id, "Person");
        logger.debug("Short Query 1 called on person id: {}", person_id);

        Vertex cityV = QueryUtils.getPersonCity(root);
        LdbcShortQuery1PersonProfileResult res = new LdbcShortQuery1PersonProfileResult(
                (String) root.getProperty("firstName"),(String) root.getProperty("lastName"),
                (Long) root.getProperty("birthday"), (String) root.getProperty("locationIP"),
                (String) root.getProperty("browserUsed"),client.getVLocalId((Long)cityV.getId()), (String) root.getProperty("gender"),
                (Long) root.getProperty("creationDate"));

        resultReporter.report(result.size(), res, operation);
    } catch (SchemaViolationException e) {
    e.printStackTrace();
    resultReporter.report(-1, null, operation);
}

}
 
开发者ID:ldbc,项目名称:ldbc_snb_implementations,代码行数:25,代码来源:LdbcShortQuery1Handler.java


示例10: executeOperation

import javax.naming.directory.SchemaViolationException; //导入依赖的package包/类
@Override
public void executeOperation(LdbcUpdate3AddCommentLike operation, TitanFTMDb.BasicDbConnectionState dbConnectionState, ResultReporter reporter) throws DbException {

    TitanFTMDb.BasicClient client = dbConnectionState.client();

    try {
        Vertex person = client.getVertex(operation.personId(), "Person");
        Vertex post = client.getVertex(operation.commentId(), "Comment");
        Map<String, Object> props = new HashMap<>(1);
        props.put("creationDate", operation.creationDate().getTime());
        client.addEdge(person, post, "likes", props);

    } catch (SchemaViolationException e) {
        logger.error("invalid vertex label requested by query update");
        e.printStackTrace();
    }


    reporter.report(0, LdbcNoResult.INSTANCE,operation);
}
 
开发者ID:ldbc,项目名称:ldbc_snb_implementations,代码行数:21,代码来源:LdbcQueryU3Handler.java


示例11: executeOperation

import javax.naming.directory.SchemaViolationException; //导入依赖的package包/类
@Override
public void executeOperation(final LdbcShortQuery5MessageCreator operation,TitanFTMDb.BasicDbConnectionState dbConnectionState,ResultReporter resultReporter) throws DbException {
    long mid = operation.messageId();
    TitanFTMDb.BasicClient client = dbConnectionState.client();
    Vertex m;
    try {
        logger.debug("Short Query 5 called on message id: {}", mid);
        m = client.getVertex(mid, "Comment");
        if (m==null)
            m = client.getVertex(mid, "Post");

        GremlinPipeline<Vertex,Vertex> gp = new GremlinPipeline<>(m);
        Vertex person = gp.out("hasCreator").next();
        LdbcShortQuery5MessageCreatorResult res = new LdbcShortQuery5MessageCreatorResult(
                    client.getVLocalId((Long)person.getId()),
                    (String) person.getProperty("firstName"),(String) person.getProperty("lastName"));
        resultReporter.report(1, res, operation);

    } catch (SchemaViolationException e) {
    e.printStackTrace();
    resultReporter.report(-1, null, operation);
}

}
 
开发者ID:ldbc,项目名称:ldbc_snb_implementations,代码行数:25,代码来源:LdbcShortQuery5Handler.java


示例12: importData

import javax.naming.directory.SchemaViolationException; //导入依赖的package包/类
@Override
public boolean importData(File dir) throws IOException, SchemaViolationException {
    //Based upon http://s3.thinkaurelius.com/docs/titan/current/bulk-loading.html
    //Enabled the storage.batch-loading configuration option in bdb.conf
    //Disabled automatic type creation by setting schema.default=none in bdb.conf
    //Using a local variation of BatchLoad https://github.com/tinkerpop/blueprints/wiki/Batch-Implementation

    logger.debug("entered import data, dir is: {}", dir.getAbsolutePath() );
    if (!dir.isDirectory())
        return false;

    WorkLoadSchema s = this.workload.getSchema();
    Map<String, String> vpMap = s.getVPFileMap();
    Map<String, String> eMap = s.getEFileMap();

    TypedBatchGraph bgraph = new TypedBatchGraph(g, VertexIDType.NUMBER, 10000);
    bgraph.setVertexIdKey(IdGraph.ID);

    loadVertices(bgraph, dir, s.getVertexTypes().keySet());
    loadVertexProperties(bgraph, dir, vpMap);
    loadEdges(bgraph, dir, eMap);
    logger.debug("completed import data");
    return true;


}
 
开发者ID:ldbc,项目名称:ldbc_snb_implementations,代码行数:27,代码来源:TitanImporter.java


示例13: removeUserNotMember

import javax.naming.directory.SchemaViolationException; //导入依赖的package包/类
/**
 * Mock a managed LDAP schema violation
 */
@Test
public void removeUserNotMember() {
	final GroupLdapRepository groupRepository = newGroupLdapRepository();
	final LdapTemplate ldapTemplate = Mockito.mock(LdapTemplate.class);
	groupRepository.setTemplate(ldapTemplate);
	Mockito.doThrow(new org.springframework.ldap.SchemaViolationException(new SchemaViolationException("any"))).when(ldapTemplate)
			.modifyAttributes(ArgumentMatchers.any(LdapName.class), ArgumentMatchers.any());
	removeUser(groupRepository);
}
 
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:13,代码来源:GroupLdapRepositoryTest.java


示例14: createSubcontext

import javax.naming.directory.SchemaViolationException; //导入依赖的package包/类
@Override
public DirContext createSubcontext(Name name, Attributes attributes)
        throws NamingException {
    int size = name.size();
    Hashtable<String, Object> subSchemaTree = doLookup(name
            .getPrefix(size - 1), size - 1);

    if (null == attributes || attributes.size() == 0) {
        // jndi.8D=Must supply attributes describing schema
        throw new SchemaViolationException(Messages.getString("jndi.8D")); //$NON-NLS-1$
    }

    if (level - size == 2) {
        // jndi.8E=Cannot create new entry under schema root
        throw new SchemaViolationException(Messages.getString("jndi.8E")); //$NON-NLS-1$
    }

    String subSchemaType = name.getSuffix(size - 1).toString();

    if (subSchemaTree.get(subSchemaType.toLowerCase()) != null) {
        throw new NameAlreadyBoundException(subSchemaType);
    }

    String schemaLine = SchemaParser.format(attributes);

    ModifyOp op = new ModifyOp(ldapContext.subschemasubentry);
    Name modifySchemaName = name.getPrefix(size - 1).addAll(rdn);
    BasicAttribute schemaEntry = new LdapAttribute(new BasicAttribute(
            jndi2ldap(modifySchemaName.toString()), schemaLine), ldapContext);
    op.addModification(OperationJndi2Ldap[DirContext.ADD_ATTRIBUTE],
            new LdapAttribute(schemaEntry, ldapContext));
    try {
        doBasicOperation(op);
        subSchemaTree.put(subSchemaType.toLowerCase(), schemaLine);
    } catch (ReferralException e) {
        // TODO
    }

    return (DirContext) lookup(name);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:41,代码来源:LdapSchemaContextImpl.java


示例15: validateVHeader

import javax.naming.directory.SchemaViolationException; //导入依赖的package包/类
/**
 * Validates the file header against the schema used by the importer
 *
 * @param s      schema to validate against
 * @param vLabel vertex type to validate against
 * @param header header of csv file
 * @return suffix of this vertex
 */
private short validateVHeader(WorkLoadSchema s, String vLabel, String[] header) throws SchemaViolationException {
    Set<String> props = s.getVertexProperties().get(vLabel);
    if (props == null)
        throw new SchemaViolationException("No properties found for the vertex label " + vLabel);

    if (!header[0].equals("id") && !header[0].endsWith(".id"))
        throw new SchemaViolationException("First column of " + vLabel
                + " is not labeled 'id', but:" + header[0]);

    for (String col : header) {
        if (col.equals("id") || col.endsWith(".id"))
            continue;

        if (!props.contains(col)) {
            /*
            This is a due to the fact that Titan has
            global property keys and language has SINGLE
            cardinality for Post.language and LIST cardinality
            in Person.language.
            */
            if (col.equals("language") && props.contains("lang"))
                continue;
            else
                throw new SchemaViolationException("Unknown property for vertex Type" + vLabel
                        + ", found " + col + " expected " + props);
        }


        if (s.getVPropertyClass(vLabel, col) == null)
            throw new SchemaViolationException("Class definition missing for " + vLabel + "." + col);
    }

    return typeMultMap.get(vLabel).shortValue();

}
 
开发者ID:ldbc,项目名称:ldbc_snb_implementations,代码行数:44,代码来源:TitanImporter.java


示例16: validateEHeader

import javax.naming.directory.SchemaViolationException; //导入依赖的package包/类
/**
 * Validates the file header against the schema used by the importer
 *
 * @param s       schema to validate against
 * @param eTriple edge triple to validate against (triple = Vertex.Edge.Vertex)
 * @param header  header of csv file
 * @return short array of size two with the suffixes of
 * the source ([0]) and target ([1]) vertices
 */
private short[] validateEHeader(WorkLoadSchema s, String eTriple, String[] header)
        throws SchemaViolationException, IllegalArgumentException {
    String[] triple = eTriple.split(TUPLESPLIT);
    if (triple.length != 3)
        throw new IllegalArgumentException("Expected parameter eTriple to " +
                "contain a string with two '.' delimiters, found" + eTriple);
    String vF = triple[0];
    String eLabel = triple[1];
    String vT = triple[2];

    Set<String> vTypes = s.getVertexTypes().keySet();
    if (!vTypes.contains(vF) || !vTypes.contains(vT))
        throw new SchemaViolationException("Vertex types not found for triple" + eTriple + ", found " + vTypes);

    Set<String> eTypes = s.getEdgeTypes();
    if (!eTypes.contains(eLabel))
        throw new SchemaViolationException("Edge type not found for triple" + eTriple + ", found " + eTypes);

    //This may be null and that's fine, not all edges have properties
    Set<String> props = s.getEdgeProperties().get(eLabel);

    if (!header[0].equals(vF + ".id"))
        throw new SchemaViolationException("First column is not labeled " + vF + ".id, but:" + header[0]);

    if (!header[1].equals(vT + ".id"))
        throw new SchemaViolationException("Second column is not labeled " + vT + ".id, but:" + header[0]);

    for (String col : header) {
        if (col.contains(".id"))
            continue;

        if (props == null || !props.contains(col))
            throw new SchemaViolationException("Unknown property, found " + col + "expected" + props);
    }

    return new short[]{typeMultMap.get(vF).shortValue(), typeMultMap.get(vT).shortValue()};
}
 
开发者ID:ldbc,项目名称:ldbc_snb_implementations,代码行数:47,代码来源:TitanImporter.java


示例17: destroySubcontext

import javax.naming.directory.SchemaViolationException; //导入依赖的package包/类
@Override
public void destroySubcontext(Name name) throws NamingException {
    int size = name.size();
    Hashtable<String, Object> subSchemaTree = doLookup(name
            .getPrefix(size - 1), size - 1);

    String subSchemaType = name.getSuffix(size - 1).toString()
            .toLowerCase();

    Object schema = subSchemaTree.get(jndi2ldap(subSchemaType));
    if (schema == null) {
        // Return silently.
        return;
    }

    if (level - size == 2) {
        // ldap.37=Can't delete schema root
        throw new SchemaViolationException(Messages.getString("ldap.37")); //$NON-NLS-1$
    }

    if (level == size) {
        // Return silently.
        return;
    }

    String schemaLine = schema.toString();
    if (schema instanceof Hashtable) {
        Hashtable<String, Object> table = (Hashtable<String, Object>) schema;
        schemaLine = table.get(SchemaParser.ORIG).toString();
    }

    ModifyOp op = new ModifyOp(ldapContext.subschemasubentry);
    Name modifySchemaName = name.getPrefix(size - 1).addAll(rdn);
    BasicAttribute schemaEntry = new LdapAttribute(new BasicAttribute(
            jndi2ldap(modifySchemaName.toString()), schemaLine), ldapContext);
    op.addModification(OperationJndi2Ldap[DirContext.REMOVE_ATTRIBUTE],
            new LdapAttribute(schemaEntry, ldapContext));
    try {
        doBasicOperation(op);
        subSchemaTree.remove(subSchemaType);
    } catch (ReferralException e) {
        // TODO
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:45,代码来源:LdapSchemaContextImpl.java


示例18: executeOperation

import javax.naming.directory.SchemaViolationException; //导入依赖的package包/类
@Override
public void executeOperation(final LdbcShortQuery6MessageForum operation,TitanFTMDb.BasicDbConnectionState dbConnectionState,ResultReporter resultReporter) throws DbException {
    long mid = operation.messageId();
    TitanFTMDb.BasicClient client = dbConnectionState.client();
    Vertex m;
    try {
        boolean isComment = true;
        logger.debug("Short Query 6 called on message id: {}", mid);
        m = client.getVertex(mid, "Comment");
        if (m==null) {
            m = client.getVertex(mid, "Post");
            isComment = false;
        }

        GremlinPipeline<Vertex,Vertex> gp = new GremlinPipeline<>(m);
        Iterator<Row> qResult;
        if (isComment) {
            qResult = gp.as("start").out("replyOf")
                    .loop("start", QueryUtils.LOOPTRUEFUNC, QueryUtils.LOOPTRUEFUNC).filter(QueryUtils.ONLYPOSTS).as("post")
                    .in("containerOf").as("forum").out("hasModerator").as("person").select();
        } else {

            qResult = gp.in("containerOf").as("forum").out("hasModerator").as("person").select();
        }


        if (!qResult.hasNext())
        {
            logger.error("Unexpected empty set");
            resultReporter.report(-1, new LdbcShortQuery6MessageForumResult(0,"",0,"",""), operation);
        } else {

        Row r = qResult.next();
            Vertex forum = (Vertex)r.getColumn("forum");
            Vertex person = (Vertex)r.getColumn("person");

            LdbcShortQuery6MessageForumResult res = new LdbcShortQuery6MessageForumResult(
                    client.getVLocalId((Long)forum.getId()),
                    (String)forum.getProperty("title"),
                    client.getVLocalId((Long)person.getId()),
                    (String) person.getProperty("firstName"),(String) person.getProperty("lastName"));
            resultReporter.report(1, res, operation); }
    } catch (SchemaViolationException e) {
    e.printStackTrace();
        resultReporter.report(-1, new LdbcShortQuery6MessageForumResult(0,"",0,"",""), operation);

}

}
 
开发者ID:ldbc,项目名称:ldbc_snb_implementations,代码行数:50,代码来源:LdbcShortQuery6Handler.java


示例19: executeOperation

import javax.naming.directory.SchemaViolationException; //导入依赖的package包/类
@Override
public void executeOperation(final LdbcQuery7 operation,TitanFTMDb.BasicDbConnectionState dbConnectionState,ResultReporter resultReporter) throws DbException {
    long person_id = operation.personId();
    final int limit = operation.limit();

    logger.debug("Query 7 called on Person id: {}",
            person_id);
    TitanFTMDb.BasicClient client = dbConnectionState.client();

    Vertex root = null;
    try {
        root = client.getVertex(person_id, "Person");
    } catch (SchemaViolationException e) {
        e.printStackTrace();
    }

    GremlinPipeline<Vertex, Vertex> gp = (new GremlinPipeline<>(root));
    Set<Vertex> friends = new HashSet<>();
    gp.out("knows").fill(friends);
    gp = (new GremlinPipeline<>(root));
    Iterable<Row> it = gp.as("root").in("hasCreator").as("post").inE("likes").as("like").outV().as("liker")
            .select();

    Map<Vertex, LdbcQuery7Result> qRes = new HashMap<>();
    for (Row r : it) {
        Vertex post = (Vertex) r.getColumn(1);
        Edge like = (Edge) r.getColumn(2);
        Vertex liker = (Vertex) r.getColumn(3);
        boolean isNotFriend = (!friends.contains(liker));
        long id = client.getVLocalId((Long) liker.getId());
        String fName = liker.getProperty("firstName");
        String lName = liker.getProperty("lastName");
        long lcDate = like.getProperty("creationDate");
        long pcDate = post.getProperty("creationDate");
        long postID = client.getVLocalId((Long) post.getId());
        String content = post.getProperty("content");
        if (content.length() == 0)
            content = post.getProperty("imageFile");

        int latency = (int) ((lcDate - pcDate) / 60000);
        LdbcQuery7Result res = new LdbcQuery7Result(id, fName, lName, lcDate, postID, content, latency, isNotFriend);
        //if liker has res, replace according to recent like, and then lower likeid if time is the same
        if (qRes.containsKey(liker)) {
            LdbcQuery7Result other = qRes.get(liker);
            if (other.likeCreationDate() > res.likeCreationDate())
                continue;
            else if (other.likeCreationDate() == res.likeCreationDate() && other.commentOrPostId() < res.commentOrPostId())
                continue;
        }

        /*it is implied from the fact that the program reached this point that either this person has not been
         recorded in qRes yet or that the current like is more recent or it is as recent as the other but with
         a lower postID */
        qRes.put(liker, res);

    }

    List<LdbcQuery7Result> result = new ArrayList<>(qRes.values());
    Collections.sort(result, new Comparator<LdbcQuery7Result>() {
        @Override
        public int compare(LdbcQuery7Result o1, LdbcQuery7Result o2) {
            if (o1.likeCreationDate() == o2.likeCreationDate())
                return Long.compare(o1.personId(), o2.personId());
            return Long.compare(o2.likeCreationDate(), o1.likeCreationDate());
        }
    });
    if (result.size() > limit)
        result = result.subList(0, limit);

    resultReporter.report(result.size(), result, operation);
}
 
开发者ID:ldbc,项目名称:ldbc_snb_implementations,代码行数:72,代码来源:LdbcQuery7Handler.java


示例20: executeOperation

import javax.naming.directory.SchemaViolationException; //导入依赖的package包/类
@Override
public void executeOperation(final LdbcShortQuery7MessageReplies operation,TitanFTMDb.BasicDbConnectionState dbConnectionState,ResultReporter resultReporter) throws DbException {
    long mid = operation.messageId();
    TitanFTMDb.BasicClient client = dbConnectionState.client();
    List<LdbcShortQuery7MessageRepliesResult> result = new ArrayList<>();
    Vertex m;
    try {
        logger.debug("Short Query 7 called on message id: {}", mid);
        m = client.getVertex(mid, "Comment");
        if (m==null)
            m = client.getVertex(mid, "Post");

        GremlinPipeline<Vertex,Vertex> gp = new GremlinPipeline<>(m);
        Iterable<Row> qResult = gp.in("replyOf").as("reply").out("hasCreator").as("person")
                .select().order(new PipeFunction<Pair<Row, Row>, Integer>() {
                    @Override
                    public Integer compute(Pair<Row, Row> argument) {
                        long cid1 = (Long)((Vertex)argument.getA().getColumn("reply")).getId();
                        long cid2 = (Long)((Vertex)argument.getB().getColumn("reply")).getId();
                        if (cid1==cid2)
                        {
                            long aid1 = (Long)((Vertex)argument.getA().getColumn("person")).getId();
                            long aid2 = (Long)((Vertex)argument.getB().getColumn("person")).getId();
                            return Long.compare(aid2,aid1);
                        } else
                            return Long.compare(cid2,cid1);
                    }
                });

        GremlinPipeline<Vertex,Vertex> gpF = new GremlinPipeline<>(m);
        Set<Vertex> friends = new HashSet<>();
        gpF.out("hasCreator").out("knows").fill(friends);

        for (Row r : qResult) {
            Vertex reply = (Vertex) r.getColumn("reply");
            Vertex person = (Vertex) r.getColumn("person");

            String content = reply.getProperty("content");
            if (content.length() == 0)
                content = reply.getProperty("imageFile");

            boolean knows = friends.contains(person);
            LdbcShortQuery7MessageRepliesResult res = new LdbcShortQuery7MessageRepliesResult(
                    client.getVLocalId((Long) reply.getId()),content,(Long)reply.getProperty("creationDate"),
                    client.getVLocalId((Long) person.getId()),
                    (String) person.getProperty("firstName"), (String) person.getProperty("lastName"),knows);
            resultReporter.report(1, result, operation);
            result.add(res);
        }
    } catch (SchemaViolationException e) {
    e.printStackTrace();
    resultReporter.report(-1, new ArrayList<LdbcShortQuery7MessageRepliesResult>(Collections.singletonList(new LdbcShortQuery7MessageRepliesResult(0,"",0,0,"","",false))), operation);
}

}
 
开发者ID:ldbc,项目名称:ldbc_snb_implementations,代码行数:56,代码来源:LdbcShortQuery7Handler.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IoUtils类代码示例发布时间:2022-05-22
下一篇:
Java TaggedComponentFactoryFinderImpl类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap