Beispiel #1
7
  public SelectMany05Bean() {

    HobbitBean[] hobbits = {
      new HobbitBean("Bilbo", "Ring Finder"),
      new HobbitBean("Frodo", "Ring Bearer"),
      new HobbitBean("Merry", "Trouble Maker"),
      new HobbitBean("Pippin", "Trouble Maker")
    };

    Set<SelectItem> items = new LinkedHashSet<SelectItem>();
    for (HobbitBean hobbit : hobbits) {
      items.add(new SelectItem(hobbit.getName()));
    }
    hobbitCollection = new TreeSet<HobbitBean>();
    hobbitCollection.addAll(Arrays.asList(hobbits));
    possibleValues = Collections.unmodifiableSet(items);
    initialSortedSetValues = new TreeSet<String>(Collections.reverseOrder());
    initialSortedSetValues.add("Pippin");
    initialSortedSetValues.add("Frodo");
    initialCollectionValues = new LinkedHashSet<String>(2);
    initialCollectionValues.add("Bilbo");
    initialCollectionValues.add("Merry");
    initialSetValues = new CopyOnWriteArraySet<String>(); // not Cloneable
    initialSetValues.add("Frodo");
    initialListValues = new Vector<String>();
    initialListValues.add("Bilbo");
    initialListValues.add("Pippin");
    initialListValues.add("Merry");
    hobbitDataModel =
        new ListDataModel<HobbitBean>(new ArrayList<HobbitBean>(Arrays.asList(hobbits)));
  }
Beispiel #2
2
  @Test
  public void kmeans_test() throws IOException {
    File file = new File(filename);
    FileReader fr = new FileReader(file);
    BufferedReader br = new BufferedReader(fr);
    String line;
    List<Vector<Double>> vectors = new ArrayList<Vector<Double>>();
    List<Integer> oc = new ArrayList<Integer>();
    while ((line = br.readLine()) != null) {
      String[] values = line.split(separator);
      Vector<Double> vector = new Vector<Double>(values.length - 1);
      for (int i = 0; i < values.length - 1; i++) {
        vector.add(i, Double.valueOf(values[i]));
      }
      vectors.add(vector);

      String clazz = values[values.length - 1];
      if (clazz.equals("Iris-setosa")) {
        oc.add(0);
      } else if (clazz.equals("Iris-versicolor")) {
        oc.add(1);
      } else {
        oc.add(2);
      }
    }
    br.close();
    fr.close();
    Matrix matrix = new Matrix(vectors);
    KMeansClustering kmeans = new KMeansClustering();
    int[] clusters = kmeans.cluster(matrix, 3);
    int[][] classMatrix = new int[3][3];
    for (int i = 0; i < oc.size(); i++) {
      classMatrix[oc.get(i)][clusters[i]]++;
    }
    System.out.println("	   setosa versicolor virginica");
    System.out.println(
        "setosa       "
            + classMatrix[0][0]
            + "       "
            + classMatrix[0][1]
            + " 	"
            + classMatrix[0][2]);
    System.out.println(
        "versicolor    "
            + classMatrix[1][0]
            + "       "
            + classMatrix[1][1]
            + " 	"
            + classMatrix[1][2]);
    System.out.println(
        "virginica     "
            + classMatrix[2][0]
            + "       "
            + classMatrix[2][1]
            + " 	"
            + classMatrix[2][2]);

    System.out.println(
        "Rand index: " + new RandIndex().calculate(oc.toArray(new Integer[oc.size()]), clusters));
  }
Beispiel #3
1
 /**
  * @param mailId
  * @return HashMap<String, List<EmailPojo>>
  * @throws Exception
  */
 private HashMap<String, List<EmailPojo>> sortByMailbox(String mailId) {
   HashMap<String, List<EmailPojo>> hashMapMail = new HashMap<String, List<EmailPojo>>();
   for (String tempId : mailId.split(",+")) {
     try {
       IEMailSentService emailSentService = new EmailSentService();
       EmailPojo emailPojo = emailSentService.getEmailPojo(tempId);
       List<EmailPojo> tempList;
       if ("9".equals(emailPojo.getEmail().getStatus())) {
         SenderConfig.initLocalSMTPConfig(emailPojo.getAccount());
         if (hashMapMail.containsKey("localsmtp")) {
           hashMapMail.get("localsmtp").add(emailPojo);
         } else {
           tempList = new ArrayList<EmailPojo>();
           tempList.add(emailPojo);
           hashMapMail.put("localsmtp", tempList);
         }
       } else {
         SenderConfig.initAccount(emailPojo.getAccount());
         if (hashMapMail.containsKey(emailPojo.getAccount().getName())) {
           hashMapMail.get(emailPojo.getAccount().getName()).add(emailPojo);
         } else {
           tempList = new ArrayList<EmailPojo>();
           tempList.add(emailPojo);
           hashMapMail.put(emailPojo.getAccount().getName(), tempList);
         }
       }
     } catch (Exception e) {
       log.error("sortByMailbox/SendMailListener/Exception: [lose mailID] [" + tempId + "]", e);
     }
   }
   return hashMapMail;
 }
Beispiel #4
1
  public String oneCookie(String name) {
    Cookie found = null;
    List<Cookie> allFound = null;
    for (Cookie cookie : getCookies()) {
      if (cookie.name().equals(name)) {
        if (found == null) {
          found = cookie;
        } else if (allFound == null) {
          allFound = new ArrayList<>(2);
          allFound.add(found);
        } else {
          allFound.add(cookie);
        }
      }
    }

    if (found == null) {
      return null;
    } else if (allFound != null) {
      StringBuilder s =
          new StringBuilder("Multiple cookies with name '").append(name).append("': ");
      int i = 0;
      for (Cookie cookie : allFound) {
        s.append(cookie.toString());
        if (++i < allFound.size()) {
          s.append(", ");
        }
      }

      throw new IllegalStateException(s.toString());
    } else {
      return found.value();
    }
  }
  /*
   * Returns list of sensors currently loaded in the system
   * */
  public static String getListOfSensors() {
    StringBuilder s = new StringBuilder();
    Iterator iter = Mappings.getAllVSensorConfigs();

    sensors.clear();
    coordinates.clear();

    while (iter.hasNext()) {
      VSensorConfig sensorConfig = (VSensorConfig) iter.next();
      Double longitude = sensorConfig.getLongitude();
      Double latitude = sensorConfig.getLatitude();
      Double altitude = sensorConfig.getAltitude();
      String sensor = sensorConfig.getName();

      if ((latitude != null) && (longitude != null) && (altitude != null)) {
        Point point = new Point(latitude, longitude, altitude);
        coordinates.add(point);
        sensors.add(sensor);
        s.append(sensor)
            .append(" => ")
            .append(longitude)
            .append(" : ")
            .append(latitude)
            .append("\n");
      }
    }
    return s.toString();
  }
Beispiel #6
0
  private List<AffinityConstraintDefinition> extractAffinityConstraintDefinitionFromLabel(
      String opStr, String valueStr, boolean keyValuePairs) {
    List<AffinityConstraintDefinition> defs = new ArrayList<AffinityConstraintDefinition>();

    AffinityOps affinityOp = null;
    for (AffinityOps op : AffinityOps.values()) {
      if (op.getLabelSymbol().equals(opStr)) {
        affinityOp = op;
        break;
      }
    }
    if (affinityOp == null) {
      return defs;
    }

    if (StringUtils.isEmpty(valueStr)) {
      return defs;
    }

    String[] values = valueStr.split(",");
    for (String value : values) {
      if (StringUtils.isEmpty(value)) {
        continue;
      }
      if (keyValuePairs && value.indexOf('=') != -1) {
        String[] pair = value.split("=");
        defs.add(new AffinityConstraintDefinition(affinityOp, pair[0], pair[1]));
      } else {
        defs.add(new AffinityConstraintDefinition(affinityOp, null, value));
      }
    }
    return defs;
  }
  ValidationResult validateUri(URL url, ValidationRequest request) throws IOException {
    String parser = request.getValue("parser", null);
    HttpRequestBase method;
    List<NameValuePair> qParams = new ArrayList<NameValuePair>();
    qParams.add(new BasicNameValuePair("out", "json"));
    if (parser != null) {
      qParams.add(new BasicNameValuePair("parser", parser));
    }
    qParams.add(new BasicNameValuePair("doc", url.toString()));

    try {
      URI uri = new URI(baseUrl);
      URI uri2 =
          URIUtils.createURI(
              uri.getScheme(),
              uri.getHost(),
              uri.getPort(),
              uri.getPath(),
              URLEncodedUtils.format(qParams, "UTF-8"),
              null);
      method = new HttpGet(uri2);
      return validate(method);
    } catch (URISyntaxException e) {
      throw new IllegalArgumentException("invalid uri. Check your baseUrl " + baseUrl, e);
    }
  }
Beispiel #8
0
 /*
  * This function inspects a .class file for a given .java file,
  * infers the package name and all used classes, and adds to "all"
  * the class file names of those classes used that have been found
  * in the same class path.
  */
 protected void java2classFiles(
     String java, File cwd, File buildDir, List<String> result, Set<String> all) {
   if (java.endsWith(".java")) java = java.substring(0, java.length() - 5) + ".class";
   else if (!java.endsWith(".class")) {
     if (!all.contains(java)) {
       if (buildDir == null) sortClassesAtEnd(result);
       result.add(java);
       all.add(java);
     }
     return;
   }
   byte[] buffer = Util.readFile(Util.makePath(cwd, java));
   if (buffer == null) {
     if (!java.endsWith("/package-info.class"))
       err.println("Warning: " + java + " does not exist.  Skipping...");
     return;
   }
   ByteCodeAnalyzer analyzer = new ByteCodeAnalyzer(buffer);
   String fullClass = analyzer.getPathForClass() + ".class";
   if (!java.endsWith(fullClass))
     throw new RuntimeException("Huh? " + fullClass + " is not a suffix of " + java);
   java = java.substring(0, java.length() - fullClass.length());
   for (String className : analyzer.getClassNames()) {
     String path = java + className + ".class";
     if (new File(Util.makePath(cwd, path)).exists() && !all.contains(path)) {
       result.add(path);
       all.add(path);
       java2classFiles(path, cwd, buildDir, result, all);
     }
   }
 }
  private void validateHosPersonalEnhet(EnhetType enhet) {
    if (enhet == null) {
      validationErrors.add("No enhet element found!");
      return;
    }

    // Check enhets id - mandatory
    if (enhet.getEnhetsId() == null
        || enhet.getEnhetsId().getExtension() == null
        || enhet.getEnhetsId().getExtension().isEmpty()) {
      validationErrors.add("No enhets-id found!");
    }

    // Check enhets o.i.d
    if (enhet.getEnhetsId() == null
        || enhet.getEnhetsId().getRoot() == null
        || !enhet.getEnhetsId().getRoot().equals(ENHET_OID)) {
      validationErrors.add("Wrong o.i.d. for enhetsId! Should be " + ENHET_OID);
    }

    // Check enhetsnamn - mandatory
    if (enhet.getEnhetsnamn() == null || enhet.getEnhetsnamn().length() < 1) {
      validationErrors.add("No enhetsnamn found!");
    }

    validateVardgivare(enhet.getVardgivare());
  }
Beispiel #10
0
 @Override
 public Map<Vendor, List<Notebook>> getNotebooksStorePresent() {
   Session session = factory.openSession();
   try {
     Query query = session.createQuery("select n from Store s join s.notebook n");
     List results = query.list();
     Map<Vendor, List<Notebook>> resMap = new HashMap<>();
     for (Iterator iter = results.iterator(); iter.hasNext(); ) {
       Notebook notebook = (Notebook) iter.next();
       Vendor key = notebook.getVendor();
       if (resMap.containsKey(key)) {
         List<Notebook> notebooks = resMap.get(key);
         notebooks.add(notebook);
         resMap.replace(key, notebooks);
       } else {
         List<Notebook> notebooks = new ArrayList<>();
         notebooks.add(notebook);
         resMap.put(key, notebooks);
       }
     }
     return resMap;
   } finally {
     if (session != null) {
       session.close();
     }
   }
 }
  private static List<FunctionDescriptor> getSuperFunctionsForMethod(
      @NotNull PsiMethodWrapper method,
      @NotNull BindingTrace trace,
      @NotNull ClassDescriptor containingClass) {
    List<FunctionDescriptor> superFunctions = Lists.newArrayList();

    Map<ClassDescriptor, JetType> superclassToSupertype =
        getSuperclassToSupertypeMap(containingClass);

    Multimap<FqName, Pair<FunctionDescriptor, PsiMethod>> superclassToFunctions =
        getSuperclassToFunctionsMultimap(method, trace.getBindingContext(), containingClass);

    for (HierarchicalMethodSignature superSignature :
        method.getPsiMethod().getHierarchicalMethodSignature().getSuperSignatures()) {
      PsiMethod superMethod = superSignature.getMethod();

      PsiClass psiClass = superMethod.getContainingClass();
      assert psiClass != null;
      String classFqNameString = psiClass.getQualifiedName();
      assert classFqNameString != null;
      FqName classFqName = new FqName(classFqNameString);

      if (!JavaToKotlinClassMap.getInstance().mapPlatformClass(classFqName).isEmpty()) {
        for (FunctionDescriptor superFun :
            JavaToKotlinMethodMap.INSTANCE.getFunctions(superMethod, containingClass)) {
          superFunctions.add(substituteSuperFunction(superclassToSupertype, superFun));
        }
        continue;
      }

      DeclarationDescriptor superFun =
          superMethod instanceof JetClsMethod
              ? trace.get(
                  BindingContext.DECLARATION_TO_DESCRIPTOR,
                  ((JetClsMethod) superMethod).getOrigin())
              : findSuperFunction(superclassToFunctions.get(classFqName), superMethod);
      if (superFun == null) {
        reportCantFindSuperFunction(method);
        continue;
      }

      assert superFun instanceof FunctionDescriptor : superFun.getClass().getName();

      superFunctions.add(
          substituteSuperFunction(superclassToSupertype, (FunctionDescriptor) superFun));
    }

    // sorting for diagnostic stability
    Collections.sort(
        superFunctions,
        new Comparator<FunctionDescriptor>() {
          @Override
          public int compare(FunctionDescriptor fun1, FunctionDescriptor fun2) {
            FqNameUnsafe fqName1 = getFQName(fun1.getContainingDeclaration());
            FqNameUnsafe fqName2 = getFQName(fun2.getContainingDeclaration());
            return fqName1.getFqName().compareTo(fqName2.getFqName());
          }
        });
    return superFunctions;
  }
Beispiel #12
0
 public void testAsCollectionWithList() {
   List list = new ArrayList();
   list.add("A");
   list.add("B");
   list.add("C");
   assertAsCollection(list, 3);
 }
 /** @generated */
 public List /*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/ getMARelTypesOnTarget() {
   List /*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/ types =
       new ArrayList /*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/();
   types.add(MolicElementTypes.Utterance_4001);
   types.add(MolicElementTypes.BRTUtterance_4002);
   return types;
 }
  @Override
  public void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    String param = request.getParameter("foo");

    java.util.List<String> valuesList = new java.util.ArrayList<String>();
    valuesList.add("safe");
    valuesList.add(param);
    valuesList.add("moresafe");

    valuesList.remove(0); // remove the 1st safe value

    String bar = valuesList.get(0); // get the param value

    try {
      java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA-512", "SUN");
    } catch (java.security.NoSuchAlgorithmException e) {
      System.out.println(
          "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)");
      throw new ServletException(e);
    } catch (java.security.NoSuchProviderException e) {
      System.out.println(
          "Problem executing hash - TestCase java.security.MessageDigest.getInstance(java.lang.String,java.lang.String)");
      throw new ServletException(e);
    }

    response
        .getWriter()
        .println(
            "Hash Test java.security.MessageDigest.getInstance(java.lang.String,java.lang.String) executed");
  }
Beispiel #15
0
  private void chartDataSet() {
    // 标签对应的柱形数据集
    List<Double> dataSeriesA = new ArrayList<Double>();
    dataSeriesA.add(66d);
    dataSeriesA.add(33d);
    dataSeriesA.add(50d);
    BarData BarDataA = new BarData("Oracle", dataSeriesA, colorORACLE);

    List<Double> dataSeriesB = new ArrayList<Double>();
    dataSeriesB.add(0.d); // 32
    dataSeriesB.add(25d);
    dataSeriesB.add(18d);
    BarData BarDataB = new BarData("SQL Server", dataSeriesB, colorMSSQL);

    List<Double> dataSeriesC = new ArrayList<Double>();
    dataSeriesC.add(79d);
    dataSeriesC.add(91d);
    dataSeriesC.add(65d);
    BarData BarDataC = new BarData("MySQL", dataSeriesC, colorMYSQL);

    List<Double> dataSeriesD = new ArrayList<Double>();
    dataSeriesD.add(52d);
    dataSeriesD.add(45d);
    dataSeriesD.add(35d);
    BarData BarDataD = new BarData("其它类型", dataSeriesD, colorOTHER);

    chartData.add(BarDataA);
    chartData.add(BarDataB);
    chartData.add(BarDataC);
    chartData.add(BarDataD);
  }
Beispiel #16
0
  private TupleValues getTupleValues(GungnirTuple tuple) {
    List<Object> outputValues = Lists.newArrayList();

    for (Field field : fields) {
      if (field instanceof FieldAccessor) {
        FieldAccessor f = (FieldAccessor) field;
        if (f.isWildcardField()) {
          if (f.getTupleAccessor() == null) {
            outputValues.addAll(tuple.getTupleValues().getValues());
          } else {
            if (tuple.getTupleName().equals(f.getTupleAccessor().getTupleName())) {
              outputValues.addAll(tuple.getTupleValues().getValues());
            }
          }
        } else if (f.isContextField()) {
          outputValues.add(getContext().get(f.getOriginalName()));
        } else {
          outputValues.add(field.getValue(tuple));
        }
      } else {
        outputValues.add(field.getValue(tuple));
      }
    }

    TupleValues tupleValues = tuple.getTupleValues();
    tupleValues.setValues(outputValues);

    return tupleValues;
  }
 /**
  * Add the widget value to evaluate to the Map of expression to evaluated
  *
  * @param formWidget the widget
  * @param expressionsToEvaluate the list of expressions to evaluate
  * @param context the context including the URL parameters
  */
 protected void addFormWidgetValueExpressionToEvaluate(
     final FormWidget formWidget,
     final List<Expression> expressionsToEvaluate,
     final Map<String, Object> context) {
   if (formWidget.getInitialValueExpression() != null) {
     final Expression expression = formWidget.getInitialValueExpression();
     expression.setName(formWidget.getId() + EXPRESSION_KEY_SEPARATOR + WIDGET_INITIAL_VALUE);
     expressionsToEvaluate.add(expression);
   } else if (WidgetType.EDITABLE_GRID.equals(formWidget.getType())
       && formWidget.getInitialValueExpressionArray() != null) {
     final List<List<Expression>> expressionArray = formWidget.getInitialValueExpressionArray();
     if (!expressionArray.isEmpty()) {
       int expressionArrayRowIndex = 0;
       for (final List<Expression> expressionArrayRow : expressionArray) {
         int expressionArrayIndex = 0;
         for (final Expression expression : expressionArrayRow) {
           expression.setName(
               formWidget.getId()
                   + EXPRESSION_KEY_SEPARATOR
                   + WIDGET_INITIAL_VALUE
                   + expressionArrayRowIndex
                   + INDEX_SEPARATOR
                   + expressionArrayIndex);
           expressionsToEvaluate.add(expression);
           expressionArrayIndex++;
         }
         expressionArrayRowIndex++;
       }
     }
   }
 }
 private static void appendSorted(
     final List<Command> commandsList,
     final CommandWrapper wrapper,
     final Map<String, CommandWrapper> wrappers) {
   if (!wrapper.afterWrappers.isEmpty()) {
     final List<CommandWrapper> afterWrappersList = wrapper.afterWrappers;
     final CommandWrapper[] afterWrappers =
         afterWrappersList.toArray(new CommandWrapper[afterWrappersList.size()]);
     for (CommandWrapper afterWrapper : afterWrappers) {
       for (int j = 0; j < afterWrapper.afterWrappers.size(); j++) {
         CommandWrapper ownAfterWrapper = afterWrapper.afterWrappers.get(j);
         if (afterWrappersList.contains(ownAfterWrapper)) {
           afterWrappersList.remove(afterWrapper);
           final int insertIndex = afterWrappersList.indexOf(ownAfterWrapper);
           afterWrappersList.add(insertIndex, afterWrapper);
         }
       }
     }
     for (CommandWrapper anAfterWrapper : afterWrappersList) {
       final CommandWrapper cwFromMap = wrappers.get(anAfterWrapper.getName());
       if (cwFromMap != null) {
         commandsList.add(cwFromMap.command);
         wrappers.remove(cwFromMap.getName());
       }
     }
     for (CommandWrapper anAfterWrapper : afterWrappersList) {
       appendSorted(commandsList, anAfterWrapper, wrappers);
     }
   }
 }
Beispiel #19
0
  protected BrowserCache.Entry getEntry(ClientRequest request) throws Exception {
    String uri = request.getUri();

    BrowserCache.Entry entry = null;
    String acceptHeader = request.getHeaders().getFirst(HttpHeaders.ACCEPT);
    if (acceptHeader != null) {
      List<WeightedMediaType> waccepts = new ArrayList<WeightedMediaType>();
      String[] split = acceptHeader.split(",");
      for (String accept : split) {
        waccepts.add(WeightedMediaType.valueOf(accept));
      }
      Collections.sort(waccepts);
      List<MediaType> accepts = new ArrayList<MediaType>();
      for (WeightedMediaType accept : waccepts) {
        accepts.add(new MediaType(accept.getType(), accept.getSubtype(), accept.getParameters()));
      }
      for (MediaType accept : accepts) {
        entry = cache.get(uri, accept);
        if (entry != null) return entry;
      }
    } else {
      return cache.getAny(uri);
    }

    return null;
  }
    /** {@inheritDoc} */
    public boolean visit(SingleVariableDeclaration node) {
      SimpleName name = node.getName();

      IBinding binding = name.resolveBinding();
      if (!(binding instanceof IVariableBinding)) return false;

      IVariableBinding varBinding = (IVariableBinding) binding;
      if (fWrittenVariables.containsKey(varBinding)) return false;

      if (fAddFinalParameters && fAddFinalLocals) {

        ModifierChangeOperation op = createAddFinalOperation(name, node);
        if (op == null) return false;

        fResult.add(op);
        return false;
      } else if (fAddFinalParameters) {
        if (!varBinding.isParameter()) return false;

        ModifierChangeOperation op = createAddFinalOperation(name, node);
        if (op == null) return false;

        fResult.add(op);
        return false;
      } else if (fAddFinalLocals) {
        if (varBinding.isParameter()) return false;

        ModifierChangeOperation op = createAddFinalOperation(name, node);
        if (op == null) return false;

        fResult.add(op);
        return false;
      }
      return false;
    }
  @Override
  public int hashCode() {
    List<Object> list = new ArrayList<Object>();

    boolean present_host = true && (is_set_host());
    list.add(present_host);
    if (present_host) list.add(host);

    boolean present_port = true;
    list.add(present_port);
    if (present_port) list.add(port);

    boolean present_uptime_secs = true;
    list.add(present_uptime_secs);
    if (present_uptime_secs) list.add(uptime_secs);

    boolean present_isLeader = true;
    list.add(present_isLeader);
    if (present_isLeader) list.add(isLeader);

    boolean present_version = true && (is_set_version());
    list.add(present_version);
    if (present_version) list.add(version);

    return list.hashCode();
  }
Beispiel #22
0
 private void checkClass(Class cls, Object obj) {
   boolean found = false;
   java.lang.Class<? extends Object> klz = obj.getClass();
   do {
     if (cls.name.equals(klz.getSimpleName())) {
       found = true;
       break;
     }
     klz = klz.getSuperclass();
   } while (klz != null);
   if (!found) {
     errors.add("Object " + obj + " should have class " + cls.name);
     return;
   }
   // Don't use klz here, we want the actual class of obj, not it's inherited root.
   String actualCls = obj.getClass().getSimpleName();
   Class concreteCls = findSubClassOf(cls.name, actualCls);
   if (concreteCls == null) {
     errors.add("No concrete subclass of " + cls.name + " corresponding to " + actualCls);
   } else {
     for (Field f : concreteCls.fields) {
       errorsForField(f, obj);
     }
   }
 }
  /** 得到新增或者有更新的APP列表 */
  private List<AppInfo> getUpdateAppInfoList(
      List<AppInfo> savedAppInfoList, List<AppInfo> localAppInfoList) {
    boolean exist = false;
    List<AppInfo> appInfoList = new ArrayList<AppInfo>();
    for (AppInfo localAppInfo : localAppInfoList) {
      exist = false;
      for (AppInfo savedAppInfo : savedAppInfoList) {
        if (localAppInfo.getAppName().equals(savedAppInfo.getAppName())
            || localAppInfo.getPackageName().equals(savedAppInfo.getPackageName())) {
          exist = true;
          if (!localAppInfo.getAppName().equals(savedAppInfo.getAppName())
              || !localAppInfo.getPackageName().equals(savedAppInfo.getPackageName())
              || !localAppInfo.getClassName().equals(savedAppInfo.getClassName())) {
            // 如果包名、APP名称、入口名有变化就需要加进来
            appInfoList.add(localAppInfo);
          }
          break;
        }
      }

      // 如果没有找到匹配的,说明是新增的,需要加进来
      if (!exist) {
        appInfoList.add(localAppInfo);
      }
    }

    return appInfoList;
  }
  protected List<SyndCategory> getCategories(
      Document doc, Map<String, Object> params, XWikiContext context) throws XWikiException {
    String mapping = (String) params.get(FIELD_CATEGORIES);
    if (mapping == null) {
      return getDefaultCategories(doc, params, context);
    }

    List<Object> categories;
    if (isVelocityCode(mapping)) {
      categories = parseList(mapping, doc, context);
    } else {
      categories = getListValue(mapping, doc, context);
    }

    List<SyndCategory> result = new ArrayList<SyndCategory>();
    for (Object category : categories) {
      if (category instanceof SyndCategory) {
        result.add((SyndCategory) category);
      } else if (category != null) {
        SyndCategory scat = new SyndCategoryImpl();
        scat.setName(category.toString());
        result.add(scat);
      }
    }
    return result;
  }
  public void validateAndCorrect() {
    if (vardAdress == null) {
      validationErrors.add("No vardAdress element found!");
      return;
    }

    HosPersonalType hosPersonal = vardAdress.getHosPersonal();
    if (hosPersonal == null) {
      validationErrors.add("No SkapadAvHosPersonal element found!");
      return;
    }

    // Check lakar id - mandatory
    if (hosPersonal.getPersonalId().getExtension() == null
        || hosPersonal.getPersonalId().getExtension().isEmpty()) {
      validationErrors.add("No personal-id found!");
    }

    // Check lakar id o.i.d.
    if (hosPersonal.getPersonalId().getRoot() == null
        || !hosPersonal.getPersonalId().getRoot().equals(HOS_PERSONAL_OID)) {
      validationErrors.add("Wrong o.i.d. for personalId! Should be " + HOS_PERSONAL_OID);
    }

    // Check lakarnamn - mandatory
    if (hosPersonal.getFullstandigtNamn() == null || hosPersonal.getFullstandigtNamn().isEmpty()) {
      validationErrors.add("No skapadAvHosPersonal fullstandigtNamn found.");
    }

    validateHosPersonalEnhet(hosPersonal.getEnhet());
  }
  protected List<String> getContributors(
      Document doc, Map<String, Object> params, XWikiContext context) throws XWikiException {
    String mapping = (String) params.get(FIELD_CONTRIBUTORS);
    if (mapping == null) {
      return getDefaultContributors(doc, params, context);
    }

    List<Object> rawContributors;
    if (isVelocityCode(mapping)) {
      rawContributors = parseList(mapping, doc, context);
    } else {
      rawContributors = getListValue(mapping, doc, context);
    }

    List<String> contributors = new ArrayList<String>();
    for (Object rawContributor : rawContributors) {
      if (rawContributor instanceof String) {
        contributors.add((String) rawContributor);
      } else {
        contributors.add(rawContributor.toString());
      }
    }

    return contributors;
  }
 static {
   mustContain = new ArrayList<>();
   mustContain.add("E1M1");
   mustContain.add("E2M1");
   mustContain.add("TITLE");
   mustContain.add("MUS_E1M1");
 }
  @Override
  protected Condition getGridSpecalCondition() {
    AndCondition ac = new AndCondition();
    // 查找当前登录用户条件
    SystemContext context = (SystemContext) this.getContext();
    // 当前用户
    Actor actor = context.getUser();

    // 定义id集合
    List<Long> ids = new ArrayList<Long>();

    // 查找属于当前用户
    ids.add(actor.getId());

    // 查找拥有的上级订阅
    List<Actor> uppers =
        this.actorService.findAncestorOrganization(
            actor.getId(),
            new Integer[] {Actor.TYPE_GROUP, Actor.TYPE_DEPARTMENT, Actor.TYPE_UNIT});

    for (Actor upper : uppers) {
      ids.add(upper.getId());
    }

    // 使用in条件
    ac.add(new InCondition("e.aid", ids));

    // 不显示草稿的
    ac.add(new NotEqualsCondition("s.status_", -1));

    return ac;
  }
 /**
  * Returns either a list of all the files connected to this program or the single file that
  * represents this program exactly, if such a file exists.
  *
  * @param request
  * @param context
  * @return
  * @throws InvalidCredentialsException
  * @throws InvalidResourceException
  * @throws MethodFailedException
  */
 private List<String> findFileObjects(TranscodeRequest request, InfrastructureContext context)
     throws InvalidCredentialsException, InvalidResourceException, MethodFailedException {
   CentralWebservice doms = CentralWebserviceFactory.getServiceInstance(context);
   List<String> fileObjectPids = new ArrayList<String>();
   List<Relation> relations = doms.getRelations(request.getObjectPid());
   for (Relation relation : relations) {
     logger.debug(
         "Relation: "
             + request.getObjectPid()
             + " "
             + relation.getPredicate()
             + " "
             + relation.getObject());
     if (relation.getPredicate().equals(HAS_EXACT_FILE_RELATION)) {
       fileObjectPids = new ArrayList<String>();
       fileObjectPids.add(relation.getObject());
       request.setHasExactFile(true);
       logger.debug(
           "Program " + request.getObjectPid() + " has an exact file " + relation.getObject());
       return fileObjectPids;
     } else if (relation.getPredicate().equals(HAS_FILE_RELATION)) {
       fileObjectPids.add(relation.getObject());
     }
   }
   return fileObjectPids;
 }
Beispiel #30
0
  /**
   * @param restoreNode
   * @return ActivityNode
   * @throws ActivityServiceException
   */
  public ActivityNode copyTo(ActivityNode restoreNode) throws ActivityServiceException {
    super.copyTo(restoreNode);
    restoreNode.setPosition(this.getPosition());
    restoreNode.setInReplyTo(this.getInReplyToId(), this.getInReplyToUrl());
    restoreNode.setAssignedTo(this.getAssignedToName(), this.getAssignedToId());

    FieldList textFields = this.getTextFields();
    FieldList dateFields = this.getDateFields();
    FieldList personFields = this.getPersonFields();
    FieldList bookmarkFields = this.getBookmarkFields();
    FieldList fileFields = this.getFileFields();
    List<Field> listOfFields = new ArrayList<Field>();
    for (Field fd : textFields) {
      listOfFields.add(fd);
    }
    for (Field fd : dateFields) {
      listOfFields.add(fd);
    }
    for (Field fd : personFields) {
      listOfFields.add(fd);
    }
    for (Field fd : bookmarkFields) {
      listOfFields.add(fd);
    }
    for (Field fd : fileFields) {
      listOfFields.add(fd);
    }
    restoreNode.setFields(listOfFields);
    return restoreNode;
  }