/** @param m The model to add. **/ public void addModel(Model m) { String name = m.getName(); models.put(name, m); }
/** @param m The model to add. **/ public void addModel(Model m) { String name = m.getName(); models.put(name, m); }
/** Get the prefix used to namespace this service **/ private String getPropertyPrefix() { String modelName = im.getModel().getName(); String prefix = "org.intermine.webservice.server.jbrowse." + modelName; return prefix; }
private String getPropertyPrefix() { String modelName = im.getModel().getName(); String propertyPrefix = "org.intermine.webservice.server.jbrowse." + modelName + "."; return propertyPrefix; }
private String getPropertyPrefix() { String modelName = im.getModel().getName(); String propertyPrefix = "org.intermine.webservice.server.jbrowse." + modelName + "."; return propertyPrefix; }
/** Get the prefix used to namespace this service **/ private String getPropertyPrefix() { String modelName = im.getModel().getName(); String prefix = "org.intermine.webservice.server.jbrowse." + modelName; return prefix; }
/** * Convert a PathQuery to XML. * * @param version the version number of the XML format * @return this template query as XML. */ public synchronized String toXml(int version) { StringWriter sw = new StringWriter(); XMLOutputFactory factory = XMLOutputFactory.newInstance(); try { XMLStreamWriter writer = factory.createXMLStreamWriter(sw); PathQueryBinding.marshal(this, "query", model.getName(), writer, version); } catch (XMLStreamException e) { throw new RuntimeException(e); } return sw.toString(); }
/** * Convert a PathQuery to XML. * * @param version the version number of the XML format * @return this template query as XML. */ public synchronized String toXml(int version) { StringWriter sw = new StringWriter(); XMLOutputFactory factory = XMLOutputFactory.newInstance(); try { XMLStreamWriter writer = factory.createXMLStreamWriter(sw); PathQueryBinding.marshal(this, "query", model.getName(), writer, version); } catch (XMLStreamException e) { throw new RuntimeException(e); } return sw.toString(); }
/** * Construct an ObjectStore with some metadata * @param model the name of the model */ protected ObjectStoreAbstractImpl(Model model) { this.model = model; Properties props = PropertiesUtil.getPropertiesStartingWith("os.query"); props = PropertiesUtil.stripStart("os.query", props); if (props.get("max-limit") != null) { maxLimit = Integer.parseInt((String) props.get("max-limit")); } if (props.get("max-offset") != null) { maxOffset = Integer.parseInt((String) props.get("max-offset")); } if (props.get("max-time") != null) { maxTime = Long.parseLong((String) props.get("max-time")); } if (props.get("max-query-parse-time") != null) { maxQueryParseTime = Long.parseLong((String) props.get("max-query-parse-time")); } LOG.info("Creating new " + getClass().getName() + " with sequence = " + sequenceNumber + ", model = \"" + model.getName() + "\""); cache = new CacheMap<Integer, InterMineObject>(getClass().getName() + " with sequence = " + sequenceNumber + ", model = \"" + model.getName() + "\" getObjectById cache"); }
/** * Construct an ObjectStore with some metadata * @param model the name of the model */ protected ObjectStoreAbstractImpl(Model model) { this.model = model; Properties props = PropertiesUtil.getPropertiesStartingWith("os.query"); props = PropertiesUtil.stripStart("os.query", props); if (props.get("max-limit") != null) { maxLimit = Integer.parseInt((String) props.get("max-limit")); } if (props.get("max-offset") != null) { maxOffset = Integer.parseInt((String) props.get("max-offset")); } if (props.get("max-time") != null) { maxTime = Long.parseLong((String) props.get("max-time")); } if (props.get("max-query-parse-time") != null) { maxQueryParseTime = Long.parseLong((String) props.get("max-query-parse-time")); } LOG.info("Creating new " + getClass().getName() + " with sequence = " + sequenceNumber + ", model = \"" + model.getName() + "\""); cache = new CacheMap<Integer, InterMineObject>(getClass().getName() + " with sequence = " + sequenceNumber + ", model = \"" + model.getName() + "\" getObjectById cache"); }
/** * Save a model, in serialized form, to the specified directory * @param model the model * @param destDir the destination directory * @throws IOException if an error occurs */ public static void saveModel(Model model, File destDir) throws IOException { write(model.toString(), new File(destDir, getFilename(MODEL, model.getName()))); }
/** * Save a model, in serialized form, to the specified directory * @param model the model * @param destDir the destination directory * @throws IOException if an error occurs */ public static void saveModel(Model model, File destDir) throws IOException { write(model.toString(), new File(destDir, getFilename(MODEL, model.getName()))); }
/** * Convert a SavedQuery to XML and write XML to given writer. * * @param query the SavedQuery * @param writer the XMLStreamWriter to write to * @param version the version number of the XML format, an attribute of the ProfileManager */ public static void marshal(SavedQuery query, XMLStreamWriter writer, int version) { try { writer.writeCharacters("\n"); writer.writeStartElement("saved-query"); writer.writeAttribute("name", query.getName()); if (query.getDateCreated() != null) { writer.writeAttribute("date-created", "" + query.getDateCreated().getTime()); } PathQueryBinding.marshal(query.getPathQuery(), query.getName(), query.getPathQuery().getModel().getName(), writer, version); writer.writeEndElement(); } catch (XMLStreamException e) { throw new RuntimeException(e); } }
/** * Convert a SavedQuery to XML and write XML to given writer. * * @param query the SavedQuery * @param writer the XMLStreamWriter to write to * @param version the version number of the XML format, an attribute of the ProfileManager */ public static void marshal(SavedQuery query, XMLStreamWriter writer, int version) { try { writer.writeCharacters("\n"); writer.writeStartElement("saved-query"); writer.writeAttribute("name", query.getName()); if (query.getDateCreated() != null) { writer.writeAttribute("date-created", "" + query.getDateCreated().getTime()); } PathQueryBinding.marshal(query.getPathQuery(), query.getName(), query.getPathQuery().getModel().getName(), writer, version); writer.writeEndElement(); } catch (XMLStreamException e) { throw new RuntimeException(e); } }
@Override protected void execute() throws ServiceException { Command cmd = getCommand(); CommandRunner runner = CommandRunner.getRunner(getProperty(CMD_RUNNER + im.getModel().getName()), im); runner.addListener(getListener()); String intro = runner.getIntro(cmd); if (intro != null) { attrs.put(JSONFormatter.KEY_INTRO, intro); } String outro = runner.getOutro(cmd); if (outro != null) { attrs.put(JSONFormatter.KEY_OUTRO, outro); } runner.run(cmd); }
@Override protected void execute() throws ServiceException { Command cmd = getCommand(); CommandRunner runner = CommandRunner.getRunner(getProperty(CMD_RUNNER + im.getModel().getName()), im); runner.addListener(getListener()); String intro = runner.getIntro(cmd); if (intro != null) { attrs.put(JSONFormatter.KEY_INTRO, intro); } String outro = runner.getOutro(cmd); if (outro != null) { attrs.put(JSONFormatter.KEY_OUTRO, outro); } runner.run(cmd); }
/** * Construct a new multi-type constraint. * @param model The model to look for types within. * @param field The subject of the constraint. * @param pcmt The constraint itself. * @return A constraint. * @throws ObjectStoreException if the constraint names types that are not in the model. */ protected static Constraint makeMultiTypeConstraint( Model model, QueryNode field, PathConstraintMultitype pcmt) throws ObjectStoreException { QueryField typeClass = new QueryField((QueryClass) field, "class"); ConstraintOp op = (pcmt.getOp() == ConstraintOp.ISA) ? ConstraintOp.IN : ConstraintOp.NOT_IN; Set<Class<?>> classes = new TreeSet<Class<?>>(new ClassNameComparator()); for (String name: pcmt.getValues()) { ClassDescriptor cd = model.getClassDescriptorByName(name); if (cd == null) { // PathQueries should take care of this, but you know. throw new ObjectStoreException( String.format("%s is not a class in the %s model", name, model.getName())); } classes.add(cd.getType()); } return new BagConstraint(typeClass, op, classes); }
/** * Construct a new multi-type constraint. * @param model The model to look for types within. * @param field The subject of the constraint. * @param pcmt The constraint itself. * @return A constraint. * @throws ObjectStoreException if the constraint names types that are not in the model. */ protected static Constraint makeMultiTypeConstraint( Model model, QueryNode field, PathConstraintMultitype pcmt) throws ObjectStoreException { QueryField typeClass = new QueryField((QueryClass) field, "class"); ConstraintOp op = (pcmt.getOp() == ConstraintOp.ISA) ? ConstraintOp.IN : ConstraintOp.NOT_IN; Set<Class<?>> classes = new TreeSet<Class<?>>(new ClassNameComparator()); for (String name: pcmt.getValues()) { ClassDescriptor cd = model.getClassDescriptorByName(name); if (cd == null) { // PathQueries should take care of this, but you know. throw new ObjectStoreException( String.format("%s is not a class in the %s model", name, model.getName())); } classes.add(cd.getType()); } return new BagConstraint(typeClass, op, classes); }
/** * Attach the model. Throws IllegalArgumentExceptions if node doesn't map onto the model. * * @param model model to attach * @throws IllegalArgumentException if class or field are not found in the model */ public void setModel(Model model) { ClassDescriptor cld = model.getClassDescriptorByName(getParentType()); if (cld == null) { throw new IllegalArgumentException("No class '" + getParentType() + "' found in model '" + model.getName() + "'."); } fd = cld.getFieldDescriptorByName(fieldName); if (fd == null) { throw new IllegalArgumentException("Class '" + cld.getName() + "' does not have field '" + fieldName + "'."); } type = TypeUtil.unqualifiedName(fd.isAttribute() ? ((AttributeDescriptor) fd).getType() : ((ReferenceDescriptor) fd) .getReferencedClassDescriptor().getName()); attribute = fd.isAttribute(); reference = fd.isReference(); collection = fd.isCollection(); this.model = model; }
/** * Attach the model. Throws IllegalArgumentExceptions if node doesn't map onto the model. * * @param model model to attach * @throws IllegalArgumentException if class or field are not found in the model */ public void setModel(Model model) { ClassDescriptor cld = model.getClassDescriptorByName(getParentType()); if (cld == null) { throw new IllegalArgumentException("No class '" + getParentType() + "' found in model '" + model.getName() + "'."); } fd = cld.getFieldDescriptorByName(fieldName); if (fd == null) { throw new IllegalArgumentException("Class '" + cld.getName() + "' does not have field '" + fieldName + "'."); } type = TypeUtil.unqualifiedName(fd.isAttribute() ? ((AttributeDescriptor) fd).getType() : ((ReferenceDescriptor) fd) .getReferencedClassDescriptor().getName()); attribute = fd.isAttribute(); reference = fd.isReference(); collection = fd.isCollection(); this.model = model; }