Search in sources :

Example 56 with org.haiku.haikudepotserver.dataobjects.auto._User

use of org.haiku.haikudepotserver.dataobjects.auto._User in project IR_Base by Linda-sunshine.

the class CLinAdaptWithHDP method loadUsers.

@Override
public void loadUsers(ArrayList<_User> userList) {
    m_userList = new ArrayList<_AdaptStruct>();
    // Init each user.
    for (_User user : userList) m_userList.add(new _HDPAdaptStruct(user, m_dim));
    m_pWeights = new double[m_gWeights.length];
}
Also used : Classifier.supervised.modelAdaptation._AdaptStruct(Classifier.supervised.modelAdaptation._AdaptStruct) structures._User(structures._User)

Example 57 with org.haiku.haikudepotserver.dataobjects.auto._User

use of org.haiku.haikudepotserver.dataobjects.auto._User in project IR_Base by Linda-sunshine.

the class CoLinAdaptWithDiffFeatureGroups method constructUserList.

@Override
void constructUserList(ArrayList<_User> userList) {
    int ASize = 2 * m_dimA;
    int BSize = 2 * m_dimB;
    // step 1: create space
    m_userList = new ArrayList<_AdaptStruct>();
    for (int i = 0; i < userList.size(); i++) {
        _User user = userList.get(i);
        m_userList.add(new _CoLinAdaptDiffFvGroupsStruct(user, m_dimA, i, m_topK, m_dimB));
    }
    m_pWeights = new double[m_gWeights.length];
    // huge space consumption
    _CoLinAdaptDiffFvGroupsStruct.sharedA = new double[getASize()];
    _CoLinAdaptDiffFvGroupsStruct.sharedB = new double[getBSize()];
    // step 2: copy each user's A and B to shared A and B in _CoLinAdaptStruct
    _CoLinAdaptDiffFvGroupsStruct user;
    for (int i = 0; i < m_userList.size(); i++) {
        user = (_CoLinAdaptDiffFvGroupsStruct) m_userList.get(i);
        System.arraycopy(user.m_A, 0, _CoLinAdaptDiffFvGroupsStruct.sharedA, ASize * i, ASize);
        System.arraycopy(user.m_B, 0, _CoLinAdaptDiffFvGroupsStruct.sharedB, BSize * i, BSize);
    }
}
Also used : Classifier.supervised.modelAdaptation._AdaptStruct(Classifier.supervised.modelAdaptation._AdaptStruct) structures._User(structures._User)

Example 58 with org.haiku.haikudepotserver.dataobjects.auto._User

use of org.haiku.haikudepotserver.dataobjects.auto._User in project haikudepotserver by haiku.

the class PkgJobApiImpl method queuePkgIconArchiveImportJob.

@Override
public QueuePkgIconArchiveImportJobResult queuePkgIconArchiveImportJob(QueuePkgIconArchiveImportJobRequest request) {
    Preconditions.checkArgument(null != request, "the request must be supplied");
    Preconditions.checkArgument(!Strings.isNullOrEmpty(request.inputDataGuid), "the input data must be identified by guid");
    final ObjectContext context = serverRuntime.newContext();
    Optional<User> user = tryObtainAuthenticatedUser(context);
    if (!permissionEvaluator.hasPermission(SecurityContextHolder.getContext().getAuthentication(), null, Permission.BULK_PKGICONIMPORTARCHIVE)) {
        throw new AccessDeniedException("attempt to import package icons, but was not authorized");
    }
    // now check that the data is present.
    jobService.tryGetData(request.inputDataGuid).orElseThrow(() -> new ObjectNotFoundException(JobData.class.getSimpleName(), request.inputDataGuid));
    // setup and go
    PkgIconImportArchiveJobSpecification spec = new PkgIconImportArchiveJobSpecification();
    spec.setOwnerUserNickname(user.map(_User::getNickname).orElse(null));
    spec.setInputDataGuid(request.inputDataGuid);
    return new QueuePkgIconArchiveImportJobResult(jobService.submit(spec, JobSnapshot.COALESCE_STATUSES_NONE));
}
Also used : AccessDeniedException(org.springframework.security.access.AccessDeniedException) org.haiku.haikudepotserver.dataobjects.auto._User(org.haiku.haikudepotserver.dataobjects.auto._User) User(org.haiku.haikudepotserver.dataobjects.User) ObjectNotFoundException(org.haiku.haikudepotserver.api1.support.ObjectNotFoundException) org.haiku.haikudepotserver.dataobjects.auto._User(org.haiku.haikudepotserver.dataobjects.auto._User) ObjectContext(org.apache.cayenne.ObjectContext)

Example 59 with org.haiku.haikudepotserver.dataobjects.auto._User

use of org.haiku.haikudepotserver.dataobjects.auto._User in project haikudepotserver by haiku.

the class PkgJobApiImpl method queuePkgScreenshotArchiveImportJob.

@Override
public QueuePkgScreenshotArchiveImportJobResult queuePkgScreenshotArchiveImportJob(QueuePkgScreenshotArchiveImportJobRequest request) {
    Preconditions.checkArgument(null != request, "the request must be supplied");
    Preconditions.checkArgument(StringUtils.isNotBlank(request.inputDataGuid), "the data guid must be supplied");
    Preconditions.checkArgument(null != request.importStrategy, "the import strategy must be supplied");
    final ObjectContext context = serverRuntime.newContext();
    Optional<User> user = tryObtainAuthenticatedUser(context);
    if (!permissionEvaluator.hasPermission(SecurityContextHolder.getContext().getAuthentication(), null, Permission.BULK_PKGSCREENSHOTIMPORTARCHIVE)) {
        throw new AccessDeniedException("attempt to import package screenshots, but was not authorized");
    }
    // now check that the data is present.
    jobService.tryGetData(request.inputDataGuid).orElseThrow(() -> new ObjectNotFoundException(JobData.class.getSimpleName(), request.inputDataGuid));
    // setup and go
    PkgScreenshotImportArchiveJobSpecification spec = new PkgScreenshotImportArchiveJobSpecification();
    spec.setOwnerUserNickname(user.map(_User::getNickname).orElse(null));
    spec.setInputDataGuid(request.inputDataGuid);
    spec.setImportStrategy(PkgScreenshotImportArchiveJobSpecification.ImportStrategy.valueOf(request.importStrategy.name()));
    return new QueuePkgScreenshotArchiveImportJobResult(jobService.submit(spec, JobSnapshot.COALESCE_STATUSES_NONE));
}
Also used : AccessDeniedException(org.springframework.security.access.AccessDeniedException) org.haiku.haikudepotserver.dataobjects.auto._User(org.haiku.haikudepotserver.dataobjects.auto._User) User(org.haiku.haikudepotserver.dataobjects.User) ObjectNotFoundException(org.haiku.haikudepotserver.api1.support.ObjectNotFoundException) org.haiku.haikudepotserver.dataobjects.auto._User(org.haiku.haikudepotserver.dataobjects.auto._User) ObjectContext(org.apache.cayenne.ObjectContext)

Aggregations

structures._User (structures._User)56 Classifier.supervised.modelAdaptation._AdaptStruct (Classifier.supervised.modelAdaptation._AdaptStruct)15 File (java.io.File)10 IOException (java.io.IOException)10 structures._Review (structures._Review)10 ArrayList (java.util.ArrayList)6 PrintWriter (java.io.PrintWriter)5 BufferedReader (java.io.BufferedReader)4 FileInputStream (java.io.FileInputStream)4 InputStreamReader (java.io.InputStreamReader)4 HashMap (java.util.HashMap)3 ObjectContext (org.apache.cayenne.ObjectContext)3 ObjectNotFoundException (org.haiku.haikudepotserver.api1.support.ObjectNotFoundException)3 User (org.haiku.haikudepotserver.dataobjects.User)3 org.haiku.haikudepotserver.dataobjects.auto._User (org.haiku.haikudepotserver.dataobjects.auto._User)3 AccessDeniedException (org.springframework.security.access.AccessDeniedException)3 InvalidFormatException (opennlp.tools.util.InvalidFormatException)2 structures._SparseFeature (structures._SparseFeature)2 FileNotFoundException (java.io.FileNotFoundException)1 HashSet (java.util.HashSet)1