Пример #1
0
  public SchemaItem getPropertyTypeSchema(
      SchemaElementComplex parentComplexProperty, EventAdapterService eventAdapterService) {
    Property lastProperty = null;
    SchemaElementComplex complexElement = parentComplexProperty;

    for (Iterator<Property> it = properties.iterator(); it.hasNext(); ) {
      Property property = it.next();
      lastProperty = property;

      if (it.hasNext()) {
        SchemaItem childSchemaItem =
            property.getPropertyTypeSchema(complexElement, eventAdapterService);
        if (childSchemaItem == null) {
          // if the property is not valid, return null
          return null;
        }

        if ((childSchemaItem instanceof SchemaItemAttribute)
            || (childSchemaItem instanceof SchemaElementSimple)) {
          return null;
        }

        complexElement = (SchemaElementComplex) childSchemaItem;
      }
    }

    return lastProperty.getPropertyTypeSchema(complexElement, eventAdapterService);
  }
Пример #2
0
  public GenericPropertyDesc getPropertyTypeGeneric(
      BeanEventType eventType, EventAdapterService eventAdapterService) {
    GenericPropertyDesc result = null;

    for (Iterator<Property> it = properties.iterator(); it.hasNext(); ) {
      Property property = it.next();
      result = property.getPropertyTypeGeneric(eventType, eventAdapterService);

      if (result == null) {
        // property not found, return null
        return null;
      }

      if (it.hasNext()) {
        // Map cannot be used to further nest as the type cannot be determined
        if (result.getType() == Map.class) {
          return null;
        }

        if (result.getType().isArray()) {
          return null;
        }

        eventType =
            eventAdapterService
                .getBeanEventTypeFactory()
                .createBeanType(result.getType().getName(), result.getType(), false, false, false);
      }
    }

    return result;
  }
 @Nullable
 private Ref<PyType> getTypeOfProperty(
     @Nullable PyType qualifierType, @NotNull String name, @NotNull TypeEvalContext context) {
   if (qualifierType instanceof PyClassType) {
     final PyClassType classType = (PyClassType) qualifierType;
     PyClass pyClass = classType.getPyClass();
     Property property = pyClass.findProperty(name, true);
     if (property != null) {
       if (classType.isDefinition()) {
         return Ref.<PyType>create(
             PyBuiltinCache.getInstance(pyClass).getObjectType(PyNames.PROPERTY));
       }
       if (AccessDirection.of(this) == AccessDirection.READ) {
         final PyType type = property.getType(context);
         if (type != null) {
           return Ref.create(type);
         }
       }
       return Ref.create();
     }
   } else if (qualifierType instanceof PyUnionType) {
     final PyUnionType unionType = (PyUnionType) qualifierType;
     for (PyType type : unionType.getMembers()) {
       final Ref<PyType> result = getTypeOfProperty(type, name, context);
       if (result != null) {
         return result;
       }
     }
   }
   return null;
 }
Пример #4
0
  public Class getPropertyType(BeanEventType eventType, EventAdapterService eventAdapterService) {
    Class result = null;

    for (Iterator<Property> it = properties.iterator(); it.hasNext(); ) {
      Property property = it.next();
      result = property.getPropertyType(eventType, eventAdapterService);

      if (result == null) {
        // property not found, return null
        return null;
      }

      if (it.hasNext()) {
        // Map cannot be used to further nest as the type cannot be determined
        if (result == Map.class) {
          return null;
        }

        if (result.isArray()
            || result.isPrimitive()
            || JavaClassHelper.isJavaBuiltinDataType(result)) {
          return null;
        }

        eventType =
            eventAdapterService
                .getBeanEventTypeFactory()
                .createBeanType(result.getName(), result, false, false, false);
      }
    }

    return result;
  }
Пример #5
0
  @Test
  public void testQueryByProperty() throws IOException {

    org.seadva.registry.database.model.obj.vaRegistry.Collection collection =
        new org.seadva.registry.database.model.obj.vaRegistry.Collection();
    collection.setId(UUID.randomUUID().toString());
    collection.setName("test");
    collection.setVersionNum("1");
    collection.setIsObsolete(0);
    collection.setEntityName("test");
    collection.setEntityCreatedTime(new Date());
    collection.setEntityLastUpdatedTime(new Date());
    collection.setState(client.getStateByName("PublishedObject"));

    Property property = new Property();
    property.setMetadata(client.getMetadataByType("abstract"));
    property.setValuestr("value_1.0");
    collection.addProperty(property);

    client.postCollection(collection);

    List<BaseEntity> entityList =
        client.queryByProperty("abstract", "value_1.0", QueryAttributeType.PROPERTY);
    assertTrue(entityList.size() > 0);
  }
Пример #6
0
 /**
  * Validate a set of properties for a description, and return a report.
  *
  * @param props the input properties
  * @param desc the configuration description
  * @return the validation report
  */
 public static Report validate(final Properties props, final Description desc) {
   final Report report = new Report();
   final List<Property> properties = desc.getProperties();
   if (null != properties) {
     for (final Property property : properties) {
       final String key = property.getName();
       final String value = props.getProperty(key);
       if (null == value || "".equals(value)) {
         if (property.isRequired()) {
           report.errors.put(key, "required");
           continue;
         }
       } else {
         // try to validate
         final Property.Validator validator = property.getValidator();
         if (null != validator) {
           try {
             if (!validator.isValid(value)) {
               report.errors.put(key, "Invalid value");
             }
           } catch (ValidationException e) {
             report.errors.put(key, "Invalid value: " + e.getMessage());
           }
         }
       }
     }
   }
   return report;
 }
Пример #7
0
  void init3rdPass() {
    for (Property property : properties) {
      property.init3ndPass();
    }

    init3rdPassRelations();
    init3rdPassAdditionalImports();
  }
Пример #8
0
 public boolean isDynamic() {
   for (Property property : properties) {
     if (property.isDynamic()) {
       return true;
     }
   }
   return false;
 }
Пример #9
0
 public String[] toPropertyArray() {
   List<String> propertyNames = new ArrayList<String>();
   for (Property property : properties) {
     String[] nested = property.toPropertyArray();
     propertyNames.addAll(Arrays.asList(nested));
   }
   return propertyNames.toArray(new String[propertyNames.size()]);
 }
Пример #10
0
 public void toPropertyEPL(StringWriter writer) {
   String delimiter = "";
   for (Property property : properties) {
     writer.append(delimiter);
     property.toPropertyEPL(writer);
     delimiter = ".";
   }
 }
  /**
   * Index all the resources in a Jena Model to ES
   *
   * @param model the model to index
   * @param bulkRequest a BulkRequestBuilder
   * @param getPropLabel if set to true all URI property values will be indexed as their label. The
   *     label is taken as the value of one of the properties set in {@link #uriDescriptionList}.
   */
  private void addModelToES(Model model, BulkRequestBuilder bulkRequest, boolean getPropLabel) {
    long startTime = System.currentTimeMillis();
    long bulkLength = 0;
    HashSet<Property> properties = new HashSet<Property>();

    StmtIterator it = model.listStatements();
    while (it.hasNext()) {
      Statement st = it.nextStatement();
      Property prop = st.getPredicate();
      String property = prop.toString();

      if (rdfPropList.isEmpty()
          || (isWhitePropList && rdfPropList.contains(property))
          || (!isWhitePropList && !rdfPropList.contains(property))
          || (normalizeProp.containsKey(property))) {
        properties.add(prop);
      }
    }

    ResIterator resIt = model.listSubjects();

    while (resIt.hasNext()) {
      Resource rs = resIt.nextResource();
      Map<String, ArrayList<String>> jsonMap = getJsonMap(rs, properties, model, getPropLabel);

      bulkRequest.add(
          client.prepareIndex(indexName, typeName, rs.toString()).setSource(mapToString(jsonMap)));
      bulkLength++;

      // We want to execute the bulk for every  DEFAULT_BULK_SIZE requests
      if (bulkLength % EEASettings.DEFAULT_BULK_SIZE == 0) {
        BulkResponse bulkResponse = bulkRequest.execute().actionGet();
        // After executing, flush the BulkRequestBuilder.
        bulkRequest = client.prepareBulk();

        if (bulkResponse.hasFailures()) {
          processBulkResponseFailure(bulkResponse);
        }
      }
    }

    // Execute remaining requests
    if (bulkRequest.numberOfActions() > 0) {
      BulkResponse response = bulkRequest.execute().actionGet();
      // Handle failure by iterating through each bulk response item
      if (response.hasFailures()) {
        processBulkResponseFailure(response);
      }
    }

    // Show time taken to index the documents
    logger.info(
        "Indexed {} documents on {}/{} in {} seconds",
        bulkLength,
        indexName,
        typeName,
        (System.currentTimeMillis() - startTime) / 1000.0);
  }
Пример #12
0
  void init2ndPass() {
    init2ndPassNamesWithDefaults();

    for (int i = 0; i < properties.size(); i++) {
      Property property = properties.get(i);
      property.setOrdinal(i);
      property.init2ndPass();
      if (property.isPrimaryKey()) {
        propertiesPk.add(property);
      } else {
        propertiesNonPk.add(property);
      }
    }

    if (propertiesPk.size() == 1) {
      pkProperty = propertiesPk.get(0);
      pkType = schema.mapToJavaTypeNullable(pkProperty.getPropertyType());
    } else {
      pkType = "Void";
    }

    propertiesColumns = new ArrayList<Property>(properties);
    for (ToOne toOne : toOneRelations) {
      toOne.init2ndPass();
      Property[] fkProperties = toOne.getFkProperties();
      for (Property fkProperty : fkProperties) {
        if (!propertiesColumns.contains(fkProperty)) {
          propertiesColumns.add(fkProperty);
        }
      }
    }

    for (ToMany toMany : toManyRelations) {
      toMany.init2ndPass();
      // Source Properties may not be virtual, so we do not need the following code:
      // for (Property sourceProperty : toMany.getSourceProperties()) {
      // if (!propertiesColumns.contains(sourceProperty)) {
      // propertiesColumns.add(sourceProperty);
      // }
      // }
    }

    if (active == null) {
      active = schema.isUseActiveEntitiesByDefault();
    }
    active |= !toOneRelations.isEmpty() || !toManyRelations.isEmpty();

    if (hasKeepSections == null) {
      hasKeepSections = schema.isHasKeepSectionsByDefault();
    }

    init2ndPassIndexNamesWithDefaults();

    for (ContentProvider contentProvider : contentProviders) {
      contentProvider.init2ndPass();
    }
  }
 @Override
 public TypeUsageNode getFieldType(String fieldName, boolean staticContext) {
   for (Property property : getAllProperties(symbolResolver())) {
     if (property.getName().equals(fieldName)) {
       return property.getTypeUsage();
     }
   }
   throw new IllegalArgumentException(fieldName);
 }
Пример #14
0
 public Property getProperty(String name) {
   Iterator<Property> iter = getProperties().iterator();
   while (iter.hasNext()) {
     Property prop = (Property) iter.next();
     if (prop.getName().equals(name)) {
       return prop;
     }
   }
   return null;
 }
Пример #15
0
 void preallocateBlockIDs(boolean[] configMarkers) {
   ConfigCategory items = config.getCategory(config.CATEGORY_BLOCK);
   for (Property prop : items.getValues().values()) {
     int id = prop.getInt();
     if (id != -1) {
       // System.out.printf("BaseMod.preallocateItemIDs: Marking block id %d as in use\n", id);
       configMarkers[id] = true;
     }
   }
 }
 public List<Property> getDirectProperties(SymbolResolver resolver) {
   List<Property> properties = new ArrayList<>();
   for (Node member : members) {
     if (member instanceof PropertyDefinition) {
       properties.add(Property.fromDefinition((PropertyDefinition) member));
     } else if (member instanceof PropertyReference) {
       properties.add(Property.fromReference((PropertyReference) member, resolver));
     }
   }
   return properties;
 }
  @Override
  public Optional<Symbol> findSymbol(String name, SymbolResolver resolver) {
    // TODO support references to methods
    for (Property property : this.getAllProperties(resolver)) {
      if (property.getName().equals(name)) {
        return Optional.of(property);
      }
    }

    return super.findSymbol(name, resolver);
  }
  private void serialize(Serializer serializer, Collection<EntityType> models) {
    for (EntityType model : models) {
      try {
        Type type = conf.getTypeMappings().getPathType(model, model, true);
        String packageName = type.getPackageName();
        String className =
            !packageName.isEmpty()
                ? (packageName + "." + type.getSimpleName())
                : type.getSimpleName();

        // skip if type is excluded class or in excluded package
        if (conf.isExcludedPackage(model.getPackageName())
            || conf.isExcludedClass(model.getFullName())) {
          continue;
        }

        Set<TypeElement> elements = context.typeElements.get(model.getFullName());

        if (elements == null) {
          elements = new HashSet<TypeElement>();
        }
        for (Property property : model.getProperties()) {
          if (property.getType().getCategory() == TypeCategory.CUSTOM) {
            Set<TypeElement> customElements =
                context.typeElements.get(property.getType().getFullName());
            if (customElements != null) {
              elements.addAll(customElements);
            }
          }
        }

        processingEnv
            .getMessager()
            .printMessage(Kind.NOTE, "Generating " + className + " for " + elements);
        JavaFileObject fileObject =
            processingEnv
                .getFiler()
                .createSourceFile(className, elements.toArray(new Element[elements.size()]));
        Writer writer = fileObject.openWriter();
        try {
          SerializerConfig serializerConfig = conf.getSerializerConfig(model);
          serializer.serialize(model, serializerConfig, new JavaWriter(writer));
        } finally {
          if (writer != null) {
            writer.close();
          }
        }

      } catch (IOException e) {
        System.err.println(e.getMessage());
        processingEnv.getMessager().printMessage(Kind.ERROR, e.getMessage());
      }
    }
  }
 @Override
 public List<Property> getPropertyList() {
   List<Property> propertyList = new ArrayList<Property>();
   Property urlProperty = new Property(WebsocketEventAdapterConstants.ADAPTER_SERVER_URL);
   urlProperty.setDisplayName(
       resourceBundle.getString(WebsocketEventAdapterConstants.ADAPTER_SERVER_URL));
   urlProperty.setHint(
       resourceBundle.getString(WebsocketEventAdapterConstants.ADAPTER_SERVER_URL_HINT));
   urlProperty.setRequired(true);
   propertyList.add(urlProperty);
   return propertyList;
 }
Пример #20
0
  @Test
  public void testTermbindsIncludesMetaproperties() throws URISyntaxException {
    Integer totalResults = null;
    Resource thisMetaPage = createMetadata(false, totalResults);

    for (Property p : expectedTermboundProperties) {
      Model model = thisMetaPage.getModel();
      if (!model.contains(null, API.property, p)) {
        fail("term bindings should include " + model.shortForm(p.getURI()));
      }
    }
  }
  @SuppressWarnings("unchecked")
  protected Property<?> createMockedProperty(Object id, Object displayName, Object value) {
    Property<String> property = mock(Property.class);

    when(property.getId()).thenReturn(id.toString()).toString();
    when(property.getDisplayName()).thenReturn(displayName.toString());
    when(property.getValueAsString()).thenReturn(value == null ? "" : value.toString());

    PropertyDefinition def = mock(PropertyDefinition.class);
    when(def.getPropertyType()).thenReturn(PropertyType.STRING);
    when(property.getDefinition()).thenReturn(def);

    return property;
  }
Пример #22
0
  protected Iterable<Property> removePropertyInternal(String name) {
    List<Property> removedProperties = new ArrayList<>();
    for (Property p : this.properties) {
      if (p.getName().equals(name)) {
        removedProperties.add(p);
      }
    }

    for (Property p : removedProperties) {
      this.properties.remove(p);
    }

    return removedProperties;
  }
Пример #23
0
  @Override
  public OntrackSVNRevisionInfo getOntrackRevisionInfo(SVNRepository repository, long revision) {

    // Gets information about the revision
    SVNRevisionInfo basicInfo = svnService.getRevisionInfo(repository, revision);
    SVNChangeLogRevision changeLogRevision =
        svnService.createChangeLogRevision(repository, basicInfo);

    // Gets the first copy event on this path after this revision
    SVNLocation firstCopy = svnService.getFirstCopyAfter(repository, basicInfo.toLocation());

    // Data to collect
    Collection<BuildView> buildViews = new ArrayList<>();
    Collection<BranchStatusView> branchStatusViews = new ArrayList<>();
    // Loops over all authorised branches
    for (Project project : structureService.getProjectList()) {
      // Filter on SVN configuration: must be present and equal to the one the revision info is
      // looked into
      Property<SVNProjectConfigurationProperty> projectSvnConfig =
          propertyService.getProperty(project, SVNProjectConfigurationPropertyType.class);
      if (!projectSvnConfig.isEmpty()
          && repository
              .getConfiguration()
              .getName()
              .equals(projectSvnConfig.getValue().getConfiguration().getName())) {
        for (Branch branch : structureService.getBranchesForProject(project.getId())) {
          // Filter on branch type
          // Filter on SVN configuration: must be present
          if (branch.getType() != BranchType.TEMPLATE_DEFINITION
              && propertyService.hasProperty(branch, SVNBranchConfigurationPropertyType.class)) {
            // Identifies a possible build given the path/revision and the first copy
            Optional<Build> build = lookupBuild(basicInfo.toLocation(), firstCopy, branch);
            // Build found
            if (build.isPresent()) {
              // Gets the build view
              BuildView buildView = structureService.getBuildView(build.get());
              // Adds it to the list
              buildViews.add(buildView);
              // Collects the promotions for the branch
              branchStatusViews.add(structureService.getEarliestPromotionsAfterBuild(build.get()));
            }
          }
        }
      }
    }

    // OK
    return new OntrackSVNRevisionInfo(
        repository.getConfiguration(), changeLogRevision, buildViews, branchStatusViews);
  }
Пример #24
0
  public EventPropertyGetter getGetterDOM() {
    List<EventPropertyGetter> getters = new LinkedList<EventPropertyGetter>();

    for (Iterator<Property> it = properties.iterator(); it.hasNext(); ) {
      Property property = it.next();
      EventPropertyGetter getter = property.getGetterDOM();
      if (getter == null) {
        return null;
      }

      getters.add(getter);
    }

    return new DOMNestedPropertyGetter(getters, null);
  }
  public void resetFrom(TemplateImpl another) {
    removeAllParsed();
    toParseSegments = another.toParseSegments;

    myKey = another.getKey();
    myString = another.myString;
    myTemplateText = another.myTemplateText;
    myGroupName = another.myGroupName;
    myId = another.myId;
    myDescription = another.myDescription;
    myShortcutChar = another.myShortcutChar;
    isToReformat = another.isToReformat;
    isToShortenLongNames = another.isToShortenLongNames;
    myIsInline = another.myIsInline;
    myTemplateContext = another.myTemplateContext.createCopy();
    isDeactivated = another.isDeactivated;
    for (Property property : Property.values()) {
      boolean value = another.getValue(property);
      if (value != Template.getDefaultValue(property)) {
        setValue(property, value);
      }
    }
    for (Variable variable : another.myVariables) {
      addVariable(
          variable.getName(),
          variable.getExpressionString(),
          variable.getDefaultValueString(),
          variable.isAlwaysStopAt());
    }
  }
Пример #26
0
 public void setMiscText(String text) {
   super.setMiscText(text);
   if (!(affected instanceof MOB)) {
     Vector parms = CMParms.parse(text.toUpperCase());
     unLocatable = parms.contains("UNLOCATABLE");
   }
 }
Пример #27
0
 @Override
 public void executeMsg(final Environmental myHost, final CMMsg msg) {
   super.executeMsg(myHost, msg);
   if (((msg.sourceMinor() == CMMsg.TYP_SHUTDOWN)
           || ((msg.targetMinor() == CMMsg.TYP_EXPIRE) && (msg.target() == affected))
           || (msg.sourceMinor() == CMMsg.TYP_ROOMRESET))
       && (affected instanceof Room)) {
     updateLot(null);
     final Vector mobs = new Vector();
     Room R = (Room) affected;
     if (R != null) {
       synchronized (("SYNC" + R.roomID()).intern()) {
         R = CMLib.map().getRoom(R);
         for (int m = 0; m < R.numInhabitants(); m++) {
           final MOB M = R.fetchInhabitant(m);
           if ((M != null)
               && (M.isSavable())
               && (M.getStartRoom() == R)
               && ((M.basePhyStats().rejuv() == 0)
                   || (M.basePhyStats().rejuv() == PhyStats.NO_REJUV))) {
             CMLib.catalog().updateCatalogIntegrity(M);
             mobs.addElement(M);
           }
         }
         if (!CMSecurity.isSaveFlag(CMSecurity.SaveFlag.NOPROPERTYMOBS))
           CMLib.database().DBUpdateTheseMOBs(R, mobs);
       }
     }
   }
 }
Пример #28
0
 @Override
 public void executeMsg(final Environmental myHost, final CMMsg msg) {
   super.executeMsg(myHost, msg);
   if ((reRollFlag)
       && (affected instanceof MOB)
       && (msg.sourceMinor() == CMMsg.TYP_LOOK)
       && (msg.source() == affected)) {
     final MOB M = msg.source();
     if ((M.session() != null) && (M.playerStats() != null)) {
       final Ability me = this;
       CMLib.threads()
           .executeRunnable(
               new Runnable() {
                 @Override
                 public void run() {
                   try {
                     CMLib.login()
                         .promptBaseCharStats(
                             M.playerStats().getTheme(), M, 300, M.session(), bonusPointsPerStat);
                     M.recoverCharStats();
                     if (rePickClass)
                       M.baseCharStats()
                           .setCurrentClass(
                               CMLib.login()
                                   .promptCharClass(M.playerStats().getTheme(), M, M.session()));
                     M.recoverCharStats();
                     M.delEffect(me);
                     M.baseCharStats().getCurrentClass().grantAbilities(M, false);
                   } catch (final IOException e) {
                   }
                 }
               });
     }
   }
 }
Пример #29
0
 @Override
 public void executeMsg(Environmental affecting, CMMsg msg) {
   super.executeMsg(affecting, msg);
   if (msg.amITarget(affecting)) {
     boolean activated = false;
     if (affecting instanceof MOB) {
       if ((msg.targetMajor(CMMsg.MASK_MALICIOUS)) && (!msg.source().isMonster()))
         activated = true;
     } else if ((affecting instanceof Food) || (affecting instanceof Drink)) {
       if ((msg.targetMinor() == CMMsg.TYP_EAT) || (msg.targetMinor() == CMMsg.TYP_DRINK))
         activated = true;
     } else if ((affecting instanceof Armor) || (affecting instanceof Weapon)) {
       if ((msg.targetMinor() == CMMsg.TYP_WEAR)
           || (msg.targetMinor() == CMMsg.TYP_HOLD)
           || (msg.targetMinor() == CMMsg.TYP_WIELD)) activated = true;
     } else if (affecting instanceof Item) {
       if ((msg.targetMinor() == CMMsg.TYP_GET)
           || (msg.targetMinor() == CMMsg.TYP_PUSH)
           || (msg.targetMinor() == CMMsg.TYP_PULL)) activated = true;
     } else activated = true;
     if (activated) {
       synchronized (killTrigger) {
         killTrigger[0] = true;
         if (!CMLib.threads().isTicking(this, Tickable.TICKID_MISCELLANEOUS))
           CMLib.threads().startTickDown(this, Tickable.TICKID_MISCELLANEOUS, 500, 1);
       }
     }
   }
 }
Пример #30
0
 protected Optional<Build> lookupBuild(
     SVNLocation location, SVNLocation firstCopy, Branch branch) {
   // Gets the SVN configuration for the branch
   Property<SVNBranchConfigurationProperty> configurationProperty =
       propertyService.getProperty(branch, SVNBranchConfigurationPropertyType.class);
   if (configurationProperty.isEmpty()) {
     return Optional.empty();
   }
   // Gets the build link
   ConfiguredBuildSvnRevisionLink<Object> revisionLink =
       buildSvnRevisionLinkService.getConfiguredBuildSvnRevisionLink(
           configurationProperty.getValue().getBuildRevisionLink());
   // Gets the earliest build
   return revisionLink.getEarliestBuild(
       branch, location, firstCopy, configurationProperty.getValue());
 }